struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darren Karstens <darrenkarst...@gmail.com>
Subject Re: If tag expression problem
Date Fri, 08 Oct 2010 10:23:58 GMT
I tried putting the current page value into the action like you said
and it works!! Still not sure why the other method failed, but its
working now :)
Thanks for the help
Darren


On Fri, Oct 8, 2010 at 11:15 AM, Darren Karstens
<darrenkarstens@gmail.com> wrote:
> Hi,
> I tried <s:if test="#it.toString() == #parameters['page']"> but still no luck.
>
> Here is the code for generating the pages array inside the action:
>
> private String pages[];
>
> // inside execute...
> pageSize = 15;
> int numberCards = this.retrieveNumberCards(db,(String)user);
> this.pages = new String[(numberCards/this.pageSize)+1];
> for (int i = 0; i<(numberCards/this.pageSize)+1; i++) this.pages[i] =
> Integer.toString(i);
>
> // getter and setters...
> public String[] getPages()
> {
>    return this.pages;
> }
>
> public void setPages(String[] pages)
> {
>    this.pages = pages;
> }
>
> On Fri, Oct 8, 2010 at 10:57 AM, Li Ying <liying.cn.2010@gmail.com> wrote:
>> I think there is a type mismatch too.
>>
>> Converting the array [pages] to strings should work,
>>
>> can you post your code, show us how you convert it?
>>
>> Or, you can try this:
>>
>> <s:if test="#it.toString() == #parameters['page']">
>>
>> see if it works.
>>
>>
>>
>>
>> 2010/10/8 Darren Karstens <darrenkarstens@gmail.com>:
>>> Hi,
>>> I have the following code that displays a list of page numbers that
>>> all have links except for the current page (defined by the request
>>> parameter 'page'):
>>>
>>> <s:iterator value="pages" var="it">
>>>  <s:if test="#it==#parameters['page']">
>>>    <s:property />
>>>  </s:if>
>>>  <s:else>
>>>    <a href="/jwg-struts/create/displayCards.action?page=<s:property
>>> />"><s:property /></a>
>>>  </s:else>
>>> </s:iterator>
>>>
>>> However this doesn't work and the if condition is alway false. I tried
>>> outputting the value of #it in each itteration and got the correct
>>> values (numbers 1-5) and done the same with the #parameters['page']
>>> and got the number 2. I also tried substituting the if tag for <s:if
>>> test="#it==2"> and this worked!! The pages array in the action was an
>>> array of ints so I thought maybe there is a type mismatch since the
>>> request parameter would be a string so I tried converting the array to
>>> strings but still no luck. Is this if tag valid? Can anyone tell me
>>> where im going wrong?
>>> Regards,
>>> Darren
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message