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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]