File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes validate in the s:iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate in the s:iterator" Watch "validate in the s:iterator" New topic

validate in the s:iterator

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I have an iterator in my Jsp ..
<s:iterator id="id" value="List" status="status">
<td ><s roperty value="%{name}" />

How can I add an If else condition to check this value of the name is equal to something and based on that I have to make this field enable or disabled..

Any suggestions..
Asim Ali

Joined: Nov 05, 2003
Posts: 26
Try using this way.

<s:iterator value="#it.days" status="rowstatus">
<s:if test="#rowstatus.odd == true">
<td style="background: grey"><s roperty/></td>
<td><s roperty/></td>
rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
Say If I wanted to get a value from a action and compare as I have shown in my post...

%{name} will get me the value from action and I wanted to compare ths value against something...

Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
If name is a property in your action class then you don't need the %{}.

To do the actual comparison it would look something like this:

<s:if test="name == xyz">

The xyz will depend on what you are doing your comparison to, but it will need to be something that can be accessed through the OGNL stack.
It is sorta covered in the JavaRanch Style Guide.
subject: validate in the s:iterator
Similar Threads
Struts2 hibernate one-to-one Mapping
Struts2 nested iterators with listboxes
Struts2: Retern all the values inside the list in my Action
struts2 custom components checkbox JSP
Struts 2 iterating enums