This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF page reload on select of selectBooleanCheckbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF page reload on select of selectBooleanCheckbox" Watch "JSF page reload on select of selectBooleanCheckbox" New topic
Author

JSF page reload on select of selectBooleanCheckbox

Pushpalatha Gowdra
Greenhorn

Joined: Jan 25, 2008
Posts: 18
Hi,

I need to reload the JSF page on check/uncheck of selectBooleanCheckbox. If we had action attribute as we have in commandButton, we could have navigated it back to the same page. Can we use valueChangeListener to achieve this? if yes, then how?

Thanks in advance!

Regards,
Pushpa
venkata swamymora
Ranch Hand

Joined: Aug 06, 2007
Posts: 33
You can do this onclick event of selectBooleanCheck box

like window.location = window.location;

this will refresh the page

venkat
venkata swamymora
Ranch Hand

Joined: Aug 06, 2007
Posts: 33
Otherwise write onselect event
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
If you write a value change listener for a check box it should look something like this:

public void handleCheckBoxChange( ValueChangeEvent valueChangedEvent) {
// Note, valueChangeEvent contains new and old values
Boolean projectStageChangeRequested = (Boolean)
valueChangedEvent.getNewValue();
// do some other things here....
}

The code an on Click handler for check box
on click="return checkProjectStageChange(this, event);"

and do this in javascript:

function checkProjectStageChange(thisObj, thisEvent) {

document.forms["addModifyProjectForm"].submit();
}
[ January 29, 2008: Message edited by: Bob Good ]
Pushpalatha Gowdra
Greenhorn

Joined: Jan 25, 2008
Posts: 18
Thanks for your kind help.

I tried both options.

Option1:
window.location = window.location;
This is taking me to my first page, and not refreshing the current page, as at that time the URL was not set to current page.

Option2:
form.submit() is working fine, but its doing some mandatory field validation, which should be skipped for page refresh.

Is there any way to submit the form by skiping the validation?

Regards,
Pushpa
Praful Sinha
Greenhorn

Joined: Jan 25, 2008
Posts: 18
To skip the Validation phase please apply imediate=true in your tag which will skip all the phases and submit the page in backing bean.
Pushpalatha Gowdra
Greenhorn

Joined: Jan 25, 2008
Posts: 18
Let me explain my problem in detail,

I have 2 command components in the form a selectBooleanCheckbox and a commandButton.

On submit from commandButton all fields should be validated, model values should be updated and response should be rendered. I mean it should follow complete request processing life cycle.

On click of selectBooleanCheckbox only the model values should be updated & the page should be reloaded (rendered again) to display the user entered values. Some fields are set to rendered=false if selectBooleanCheckbox is checked.

I have set immediate=true for selectBooleanCheckbox and calling form.submit on onclick event of selectBooleanCheckbox

so only for submit from selectBooleanCheckbox the validation should be skipped. please let me know how this can be achieved

Regards,
Pushpa
 
jQuery in Action, 2nd edition
 
subject: JSF page reload on select of selectBooleanCheckbox
 
Similar Threads
h:selectBooleanCheckbox
generate UI with binding-attribute
Refreshing the page after a 500 error
how to use command link in jsf
Help with commandLink {very basic}