aspose file tools*
The moose likes JSF and the fly likes How to put EL into setRendered()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to put EL into setRendered()?" Watch "How to put EL into setRendered()?" New topic
Author

How to put EL into setRendered()?

Sasha Baker
Greenhorn

Joined: Nov 25, 2008
Posts: 4
I need to set visibility of an UIInput component programmatical and with a binding:

<h:inputText rendered="#{mybean.visisble}" />

uiInput.setRendered(boolean); doesn't do the job.

Instead I tried:


It doesn't work.
Marius Snyman
Greenhorn

Joined: May 04, 2006
Posts: 14
Originally posted by Sasha Baker:
I need to set visibility of an UIInput component programmatical and with a binding:

<h:inputText rendered="#{mybean.visisble}" />

uiInput.setRendered(boolean); doesn't do the job.

Instead I tried:


It doesn't work.


I suggest that instead of doing:
rendered="#{mybean.visisble}"
do:
binding = "{BB.inputText}"


Then in the backing bean on some condition activate the inputText
example:
BB:
HtmlInputText inputText = new HtmlInputText();

constructor(){
inputText.setRendered(false);
}
public void someMethod(){
inputText.setRendered(false);
}

If you look at the JSF documentation you will see that when the object property is changed JSF will re-render the object. The way you have done it the re-render will not occur. Hope this helps.
Sasha Baker
Greenhorn

Joined: Nov 25, 2008
Posts: 4
Thank you for your help!

I was trying to build something like this from java code:



The ValueExpression as described above works well. My fault was to use
.setValue("#{bean.visible}");, which neither works nor results in an error message, as setValue expects a plain Object. But the String isn't parsed
as an expression value. Instead one must call .setValueExpression("value", vExp) too.

To give a more complete source example for the use of ValueExpression:


[ November 27, 2008: Message edited by: Sasha Baker ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to put EL into setRendered()?