0

Boolean works for disabled but not for if / unless

asked 2009-05-27 15:06:58 +0800

theskull gravatar image theskull
3

updated 2009-05-27 15:10:53 +0800

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>

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-05-27 17:59:32 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2009-06-06 05:07:55 +0800

davout gravatar image davout
1435 3 18

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>


If I was being pedantic I could argue that the row is only created when the model adds rows to the grid, hence the 'if' attribute should be evaluated after the page has been rendered.

I would appreciate an example of how the same result can be achieved using $EL's.

link publish delete flag offensive edit

answered 2011-10-17 04:30:56 +0800

Newion gravatar image Newion
78 1 1

>> 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.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-05-27 15:06:58 +0800

Seen: 926 times

Last updated: Oct 17 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More