You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by SudarshanP <Su...@Satyam.com> on 2007/11/13 13:10:52 UTC

conditional matching using s:if

Hi Struts2 users,

I am new to Struts2

Have a problem with s:if tag, below is the code snippet
'branchsData' is a javaobject having 'branch' as its property

Trying to generate table structure based on condition, i am afraid s:if
conditional tag is not working for me.  Let me know what is the problem with
this code and what best way to achieve this

Any help will be greatly appreciated

Thanks in advance

----------------------------- START -------------------------------------
<s:iterator value="branchsData" status="stat">
   <s:if test="%{#branchsData[%{#stat.index}].branch =='START'}">
	<table><tr>
    </s:if>
    <s:elseif test="%{#branchsData[%{#stat.index}].branch =='END'}">
	</table></tr>
    </s:elseif>
    <s:else>									
	<td><s:textfield name="%{#branchsData[%{#stat.index}].branch"
value=""></s:textfield></td>
   </s:else>
</s:iterator>
------------------------------- END ----------------------------------
-- 
View this message in context: http://www.nabble.com/conditional-matching-using-s%3Aif-tf4797396.html#a13724644
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: help - pagination using struts2

Posted by Jim Reynolds <ji...@gmail.com>.
Look into the open source project called displayTag, I think that will
save a lot of headaches and reinventing the wheel.

http://displaytag.sourceforge.net/10/jdepend-report.html




On 11/16/07, Thilo Ettelt <te...@carmunity.de> wrote:
> Hello DharmaRao,
>
> take a look at the s:iterator and s:subset Tag.
> They allow you to iterate over a list for example and also take subsets
> out of it.
> http://struts.apache.org/2.0.11/docs/tag-reference.html
>
>
> - Thilo
>
> DharmaRao.Edula@cognizant.com wrote:
> > HI
> >
> > I am not able to find out pagination using Struts2.
> >
> > Is there any tag lib ( which is similar to struts layout in Struts 1.x)
> > available in Struts2.
> >
> > Could any one guide me or send me some sample code.
> >
> > thanks and regards
> > DharmaRao
> >
> >
> > This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
> > If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
> > Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly
> > prohibited and may be unlawful.
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: help - pagination using struts2

Posted by Thilo Ettelt <te...@carmunity.de>.
Hello DharmaRao,

take a look at the s:iterator and s:subset Tag.
They allow you to iterate over a list for example and also take subsets 
out of it.
http://struts.apache.org/2.0.11/docs/tag-reference.html


- Thilo

DharmaRao.Edula@cognizant.com wrote:
> HI
>
> I am not able to find out pagination using Struts2.
>
> Is there any tag lib ( which is similar to struts layout in Struts 1.x)
> available in Struts2.
>
> Could any one guide me or send me some sample code.
>
> thanks and regards
> DharmaRao
>
>
> This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
> If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
> Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
> prohibited and may be unlawful.
>
>   
>
> ---------------------------------------------------------------------
> 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


Re: help - pagination using struts2

Posted by rahul sharma <ra...@yahoo.com>.
deko babu,
Cognizant people are supposed to be the experts
therefore they should not ask for help like this.
Unfortunately, I am also looking for the same answer
--- DharmaRao.Edula@cognizant.com wrote:

> 
> HI
> 
> I am not able to find out pagination using Struts2.
> 
> Is there any tag lib ( which is similar to struts
> layout in Struts 1.x)
> available in Struts2.
> 
> Could any one guide me or send me some sample code.
> 
> thanks and regards
> DharmaRao
> 
> 
> This e-mail and any files transmitted with it are
> for the sole use of the intended recipient(s) and
> may contain confidential and privileged information.
> If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all
> copies of the original message. 
> Any unauthorised review, use, disclosure,
> dissemination, forwarding, printing or copying of
> this email or any action taken in reliance on this
> e-mail is strictly 
> prohibited and may be unlawful.
> 
>   
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



      ____________________________________________________________________________________
Get easy, one-click access to your favorites. 
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs 

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


help - pagination using struts2

Posted by Dh...@cognizant.com.
HI

I am not able to find out pagination using Struts2.

Is there any tag lib ( which is similar to struts layout in Struts 1.x)
available in Struts2.

Could any one guide me or send me some sample code.

thanks and regards
DharmaRao


This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly 
prohibited and may be unlawful.

  

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


Re: conditional matching using s:if

Posted by SudarshanP <Su...@Satyam.com>.
Thanks for the help
Could get what i wanted by using the s:set tag. Code snippet below

----------------------
<s:iterator value="allBranches" status="stat">
 <div style="display:none"><s:set name="brname"><s:property/></s:set></div>
 <s:if test="%{#brname=='START'}">
	<table class="gridTable" id='<s:property/>'><tr>
</s:if>
<s:elseif test="%{#brname=='END'}">
	</table></tr>
</s:elseif>
<s:else>
	<th width="65"><s:property/></th>
	<td><s:textfield id="" name="%{#brname}" size="4"
value=""></s:textfield></td>
</s:else>
</s:iterator>

-----------------------



Laurie Harper wrote:
> 
> Without seeing more of your code I can't be sure, but (see inline):
> 
> SudarshanP wrote:
>> Hi Struts2 users,
>> 
>> I am new to Struts2
>> 
>> Have a problem with s:if tag, below is the code snippet
>> 'branchsData' is a javaobject having 'branch' as its property
> 
> if that's the case, why are you trying to iterate it with s:iterator?
> I'll assume below that branchsData is actually some sort of collection 
> (array or list) of objects where each object has a 'branch' property.
> 
>> Trying to generate table structure based on condition, i am afraid s:if
>> conditional tag is not working for me.  Let me know what is the problem
>> with
>> this code and what best way to achieve this
>> 
>> Any help will be greatly appreciated
>> 
>> Thanks in advance
>> 
>> ----------------------------- START -------------------------------------
>> <s:iterator value="branchsData" status="stat">
>>    <s:if test="%{#branchsData[%{#stat.index}].branch =='START'}">
>> 	<table><tr>
>>     </s:if>
>>     <s:elseif test="%{#branchsData[%{#stat.index}].branch =='END'}">
>> 	</table></tr>
>>     </s:elseif>
>>     <s:else>									
>> 	<td><s:textfield name="%{#branchsData[%{#stat.index}].branch"
>> value=""></s:textfield></td>
>>    </s:else>
>> </s:iterator>
>> ------------------------------- END ----------------------------------
> 
> It looks like you may be trying to encode presentational information in 
> your data. Those OGNL expressions look suspicious to me, too; why are 
> you trying to do the indexing manually, instead of letting s:iterator 
> handle it for you?
> 
> The simple solution is to get rid of the conditional rendering stuff 
> like so:
> 
>    <table><tr>
>    <s:iterator var="branch" value="branchsData" stat="stat">
>      <td><s:textfield name="branch"/></td>
>    </s:iterator>
>    </tr></table>
> 
> If branch=='START' and branch='END' are just placeholder/delimiter 
> entries to separate logical groups of entries, consider making your data 
> structure a list of lists of branches, where the intermediate list does 
> the grouping.
> 
> If that doesn't help, try posting a more complete description of what 
> you're trying to achieve. Maybe there are more suitable changes that can 
> be applied to your data structure and/or presentation logic to get there.
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/conditional-matching-using-s%3Aif-tf4797396.html#a13787836
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: conditional matching using s:if

Posted by Laurie Harper <la...@holoweb.net>.
Without seeing more of your code I can't be sure, but (see inline):

SudarshanP wrote:
> Hi Struts2 users,
> 
> I am new to Struts2
> 
> Have a problem with s:if tag, below is the code snippet
> 'branchsData' is a javaobject having 'branch' as its property

if that's the case, why are you trying to iterate it with s:iterator?
I'll assume below that branchsData is actually some sort of collection 
(array or list) of objects where each object has a 'branch' property.

> Trying to generate table structure based on condition, i am afraid s:if
> conditional tag is not working for me.  Let me know what is the problem with
> this code and what best way to achieve this
> 
> Any help will be greatly appreciated
> 
> Thanks in advance
> 
> ----------------------------- START -------------------------------------
> <s:iterator value="branchsData" status="stat">
>    <s:if test="%{#branchsData[%{#stat.index}].branch =='START'}">
> 	<table><tr>
>     </s:if>
>     <s:elseif test="%{#branchsData[%{#stat.index}].branch =='END'}">
> 	</table></tr>
>     </s:elseif>
>     <s:else>									
> 	<td><s:textfield name="%{#branchsData[%{#stat.index}].branch"
> value=""></s:textfield></td>
>    </s:else>
> </s:iterator>
> ------------------------------- END ----------------------------------

It looks like you may be trying to encode presentational information in 
your data. Those OGNL expressions look suspicious to me, too; why are 
you trying to do the indexing manually, instead of letting s:iterator 
handle it for you?

The simple solution is to get rid of the conditional rendering stuff 
like so:

   <table><tr>
   <s:iterator var="branch" value="branchsData" stat="stat">
     <td><s:textfield name="branch"/></td>
   </s:iterator>
   </tr></table>

If branch=='START' and branch='END' are just placeholder/delimiter 
entries to separate logical groups of entries, consider making your data 
structure a list of lists of branches, where the intermediate list does 
the grouping.

If that doesn't help, try posting a more complete description of what 
you're trying to achieve. Maybe there are more suitable changes that can 
be applied to your data structure and/or presentation logic to get there.

L.


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