• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to put EL into setRendered()?

 
Sasha Baker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic