-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
Please, can someone tell me why does this Grid doesn't work?
When the page is loaded the grid is emtpy. After hitting the Search Button, Products are loaded and the grid is field. But it is not possible to show one time a pic and the other time a label depending on the true/false coming from the bean. But it is possible to set the value disabled by this data from the bean.
Best Regards
Max
<grid id="grid_first"> <columns> <column label="ID" /> <column label="Enable" /> </columns> <rows> <row self="@{each=line}" value="@{line}"> <label id="id" value="@{line.id}" /> <label id="product_enable" value="Yes" if="@{line.enabled}"/> <image src="/img/mypic.gif" unless="@{line.enabled}"/> </row> </rows> </grid>
if and unless are renderoptions and not part of the UI-Model. The only checked 1x (while rendering the page the first time). Databinding starts after render the page.
- You can use $EL's - when there is no need for dynamic change.
- You can use @databinding and visible (maybe use an converter to reverse the boolean)
/Robert
I have the same problem with a grid where I'm using databinding. The basic problem is that the 'if' attribute has been designed for use at a grid not row level. In reality I suspect most developers want control at both levels.
A typical use case is where the component set into a grid row cell will vary according to the model row/cell data value, i.e. if its one value use a Toolbarbutton or another use a Label. Like...
grid id="grid_first"> <columns> <column label="ID" /> <column label="Enable" /> </columns> <rows> <row self="@{each=line}" value="@{line}"> <label id="id" value="@{line.id}" /> <!-- show label if product line already exists, otherwise show link --> <label id="product_enable" value="Yes" if="@{line.enabled}"/> <toolbarbutton id="addLine" title="Add product line" if="@{line.enabled == false}"/> <image src="/img/mypic.gif" unless="@{line.enabled}"/> </row> </rows> </grid>
>> You can use @databinding and visible
This will not work if you have two components sharing one model.
Example:
<hbox>
<textbox value="@{action.value}" visible="@{controller.textboxVisible}"/>
<combobox selectedItem="@{action.value}" model="@{controller.values}" visible="@{controller.textboxNotVisible}"/>
</hbox>
In this case shared model is 'action.value'. One of the components must specify binding attribute 'access='load', otherwise you will get conflicting updates of the model.
Asked: 2009-05-27 15:06:58 +0800
Seen: 926 times
Last updated: Oct 17 '11