Another solution is:
Step1, In you Action class, add a property named "page"
with get/set method, which is int type. So this property
will capture the value of request parameter, and convert
it to [int]
Step2, In you jsp, reference the "page" property and compare
it to the variable [it] in the iteration.
Code should like this:
Java:
XXXAction {
private int page;
public int getPage()...
public void setPage(int page)...
}
JSP:
<s:if test="#it == page">
2010/10/8 Li Ying <[email protected]>:
> 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 <[email protected]>:
>> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]