Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Visual JSF, checkbox and Textfield behavior

 
Jorge Bendahan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope it doesn't work.. ajax also doesn't work, i don't know what to do..
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic