Re: conditional matching using s:if

2007-11-15 Thread SudarshanP

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:nones:set name=brnames: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=65s:property//th
tds: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'}
  tabletr
 /s:if
 s:elseif test=%{#branchsData[%{#stat.index}].branch =='END'}
  /table/tr
 /s:elseif
 s:else 
  tds: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:
 
tabletr
s:iterator var=branch value=branchsData stat=stat
  tds: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]



Re: conditional matching using s:if

2007-11-14 Thread Laurie Harper

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'}
tabletr
/s:if
s:elseif test=%{#branchsData[%{#stat.index}].branch =='END'}
/table/tr
/s:elseif
s:else
  
tds: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:


  tabletr
  s:iterator var=branch value=branchsData stat=stat
tds: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]



conditional matching using s:if

2007-11-13 Thread SudarshanP

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'}
tabletr
/s:if
s:elseif test=%{#branchsData[%{#stat.index}].branch =='END'}
/table/tr
/s:elseif
s:else
tds: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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]