You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by quinquin2209 <qu...@yahoo.com.hk> on 2008/01/30 04:33:23 UTC

s:if test with empty String

Hi All,

I have an array of String "members"... where member[0] is the member id and
member[1] is the member's name.

In the jsp, I want to display member[1] if it is not empty, or member[0] if
member[1] is empty.

<s:if test="%{members[#status.index][1]} == '' ">
	<s:property value="%{distinctIssuePartyId[#status.index][0]}"/>				                    
</s:if>
<s:else>
	<s:property value="%{distinctIssuePartyId[#status.index][1]}"/>
</s:else>

However, the else logic is executed no matter member[1] is empty or not.

How can I test with empty string?

Thanks in advance

Queenie
-- 
View this message in context: http://www.nabble.com/s%3Aif-test-with-empty-String-tp15174836p15174836.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: s:if test with empty String

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,
probably u can go this way:

< s:if test="{members[#status.index][1] eq null} >
	<s:property value="%{distinctIssuePartyId[#status.index][0]}"/>				                    
</ s:if>

or 

< s:if test="{''.equals(members[#status.index][1])} >
	...
</ s:if>

this is ognl and should help u out. let me know if it works.

cheers,
ravi 



quinquin2209 wrote:
> 
> Hi All,
> 
> I have an array of String "members"... where member[0] is the member id
> and member[1] is the member's name.
> 
> In the jsp, I want to display member[1] if it is not empty, or member[0]
> if member[1] is empty.
> 
> <s:if test="%{members[#status.index][1]} == '' ">
> 	<s:property value="%{distinctIssuePartyId[#status.index][0]}"/>				                    
> </s:if>
> <s:else>
> 	<s:property value="%{distinctIssuePartyId[#status.index][1]}"/>
> </s:else>
> 
> However, the else logic is executed no matter member[1] is empty or not.
> 
> How can I test with empty string?
> 
> Thanks in advance
> 
> Queenie
> 

-- 
View this message in context: http://www.nabble.com/s%3Aif-test-with-empty-String-tp15174836p15181533.html
Sent from the Struts - User mailing list archive at Nabble.com.


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