File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Visual JSF, checkbox and Textfield behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Visual JSF, checkbox and Textfield behavior" Watch "Visual JSF, checkbox and Textfield behavior" New topic
Author

Visual JSF, checkbox and Textfield behavior

Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Hi all, i have a checkBox and a textField component, i want to enable/disable the textfield depending on wether the checkbox is checked or not. I have tried in the java code puting in checkBox1ValueChangeListener() setenable(false) and works only for disabling but i cannot enable it back. maybe with javascript i can solve this but i do not know javascript very well, can anyone help me..
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

What have you tried?

Probably a simple ValueChangeListener on the checkbox, along with an onchange="this.form.submit();" in the checkbox will go far. Have the enabled property linked to the enabled property of the textfield and you're on your way.

Show us some code, tell us what errors you're getting, and we'll walk you through it.

-Cameron McKenzie
Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
i cannot submit the page, because those two aren't the only components, i want to do something like this:
It works when i click the checkbox the first time, so it disables the textfields, but when i uncheck i doesnt set the properties of the textfields to readOnly(false)
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968



I'm wondering if FacesContext.getCurrentInstance().renderResponse(); will help. "Once the value change event is processed, the Render Response phase must be initiated by calling renderResponse() in order to avoid validations." (Burns)

-Cameron McKenzie


Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
nope it doesn't work.. ajax also doesn't work, i don't know what to do..
Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
i've tried with FacesContext.getCurrentInstance().renderResponse(); , but it doesn't work. i just want to enable/disable input on a textfield using a checkbox.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Visual JSF, checkbox and Textfield behavior
 
Similar Threads
Checkbox triger another checkbox
pass parameter from text box to applet
How to enable check box on select particular value from dropdown box
how to enable a checkbox through javascript
How to populate a value in text box