On Mon, Oct 30, 2006 at 08:46:41PM +0000, pipothebit wrote:
> I add rols and delete (throught index property of For component) but my
> rol values are not set during post, and when i go to save it to database
> all items of rols List are empty (state is not saved).

I do not really understand what you are doing, but there are different
ways to manipulate state according to elements in a For loop.

Assuming you render something like a button for each element, you
could use the current value (assigned via value) or the index
(assigned via index parameter) to associate the rendered button
with the element, so you know for which element the button has been
pressed.

Another way, if things are more complicated, is to use hand tailored
setters and getters which take into account what the current element
in the loop is, backed by a persisted property.

Lets say you have a property elementChecked (a set) and iterate
with the For component over elements:
<span jwcid="@For" source="ognl:elements" value="ognl:element">
...
</span>

In this component you have a checkbox accessing a property elementCheck.
For this property define the getter and setter as follows:
public boolean isElementCheck() {
   this.getElementChecked().contains(getElement());
}
public void setElementCheck(boolean checked);
  if (checked) {
    this.getElementChecked().add(getElement());
  } else {
    this.getElementChecked().remove(getElement());
  }
}

Well, elementChecked does not need to be persistent, if you do not need
it after the rewind.

Regards,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to