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]

Reply via email to