-
1. Re: MenuItem x actionParam as Object?
nbelaevski Apr 30, 2010 3:26 PM (in response to hwoarang)Hi Flavio,
Object can be passed as object to construct menu items using {...} expressions, however objects cannot be submitted as request parameters, only string data can be used.
-
2. Re: MenuItem x actionParam as Object?
hwoarang Apr 30, 2010 3:31 PM (in response to nbelaevski)Ok Nick.
Too bad.
Thank you for the quick reply.
-
3. Re: MenuItem x actionParam as Object?
hwoarang Apr 30, 2010 5:49 PM (in response to nbelaevski)Hi Nick.
And do you know if can I use the request parameters on rendered tag?
Let me explain:
The code below do not work:
<r:menuItem ajaxSingle="true" ignoreDupResponses="true" rendered="{id} == 0" action="#{Bean.actionMethod}"> Editar <a4j:actionparam name="id" noEscape="true" assignTo="#{Bean.object.id}" value="{id}" /> <a4j:actionparam name="item" noEscape="true" assignTo="#{Bean.object}" value="{item}" /> </r:menuItem>
But I can use the parameter {id} in javascript events like this:
<r:menuItem ajaxSingle="true" ignoreDupResponses="true" onmouseover="alert({id});" action="#{Bean.actionMethod}"> Editar <a4j:actionparam name="id" noEscape="true" assignTo="#{Bean.object.id}" value="{id}" /> <a4j:actionparam name="item" noEscape="true" assignTo="#{Bean.object}" value="{item}" /> </r:menuItem>
So, I'm doind something wrong or is not possible?
Thank you!
Flávio Henrique
-
4. Re: MenuItem x actionParam as Object?
hwoarang May 1, 2010 12:46 AM (in response to hwoarang)Hmmm.
I tried so many forms but seems when the parameter is involved in rendered tag the test always returns false.
I need to show the r:menuItem only for some rows, not all of them.
Maybe I'm testing in wrong way?
Please, take a look in this code:
<r:dataTable var="item" onRowClick="#{r:component('contextMenu')}.show(event, {'status':'#{item.status}'});" />
<r:contextMenu attached="false" id="contextMenu" disableDefaultMenu="true" submitMode="ajax">
<r:menuItem rendered="{status} == 2" />
</r:contextMenu>The problem, obviously, is the test {status} == 2. But what?
Another solution is how to solve this:
<r:componentControl event="onRowClick" for="contextMenu" operation="show">
<a4j:support ignoreDupResponses="true" event="onRowClick">
<f:setPropertyActionListener value="#{item}" target="#{Bean.object}" />
</a4j:support>
<f:param value="#{item.status}" name="status" />
</r:componentControl>
Why the setPropertyActionListener do not work to set my Bean's object. I tried all events in a4j:support. I need to define the Bean attribute to test it in the r:menuitem rendered tag.
Any tip is more than appreciated!
Thank you in advance.
Flávio Henrique
-
5. Re: MenuItem x actionParam as Object?
harut May 3, 2010 5:10 AM (in response to hwoarang)The code below do not work:
<r:menuItem ajaxSingle="true" ignoreDupResponses="true" rendered="{id} == 0" action="#{Bean.actionMethod}"> Editar <a4j:actionparam name="id" noEscape="true" assignTo="#{Bean.object.id}" value="{id}" /> <a4j:actionparam name="item" noEscape="true" assignTo="#{Bean.object}" value="{item}" /> </r:menuItem>
1. EL expression in "rendered" attribute is incorrect. It should be rendered="#{id == 0}"
2. incorrect value of actionparam -- you should add "#" -- value="#{id}"
And do you know if can I use the request parameters on rendered tag?
You need a4j:actionparam to send reqest params to server. If you need rendered attribute to contain any expression with the value of any actionparam, then write there the "value" of actionparam and not it's name...
-
6. Re: MenuItem x actionParam as Object?
hwoarang May 3, 2010 11:30 AM (in response to harut)Hi Harut. Thank you for the tip.
1. EL expression in "rendered" attribute is incorrect. It should be rendered="#{id == 0}"
I tried #{id ==0} before, but didn't work.
2. incorrect value of actionparam -- you should add "#" -- value="#{id}"
According to RF demo page (http://livedemo.exadel.com/richfaces-demo/richfaces/contextMenu.jsf?c=contextMenu&tab=usage) I must use {id} not #{id} in value attribute. Besides that {id} works fine there.
The problem is only in rendered attribute. Seems to be impossible to use the actionparam as it uses '{}' to identify and this breaks the '{} from EL expression.
Someone has a code that works to share with me? Or should I open a JIRA ticket for this?
Thank you!
Flávio Henrique
-
7. Re: MenuItem x actionParam as Object?
hwoarang May 3, 2010 1:17 PM (in response to hwoarang)Hmmm...
In fact, the actionparam is NOT related with my problem.
I want to use the f:param value, from r:componentControl, in rendered attribute:
<r:componentControl event="onRowClick" for="menu" operation="show"> <f:param value="#{item.id}" name="id" /> </r:componentControl> [...] <r:contextMenu attached="false" id="menu" disableDefaultMenu="true" submitMode="ajax"> <r:menuItem ajaxSingle="true" rendered="{id} == 1" reRender="formulario" ignoreDupResponses="true" action="#{MyBean.method}"> <b>{id}</b> </r:menuIte </r:contextMenu>
Sorry if I created confusion.
Flávio Henrique
Message was edited by: Flavio Henrique
-
8. Re: MenuItem x actionParam as Object?
nbelaevski May 3, 2010 2:51 PM (in response to hwoarang)Hi Flavio,
No, it's not possible to use {...} expressions in "rendered" attribute expression. You can workaround this using CSS, e.g. styleClass="{var.hidden ? 'display-none' : ''}", however you should be checking on the server if the component is rendered as security measure.