Display Different Sections while selecting different radio buttons
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi ,
I am quite new to JSF. I have a query . I need to display two different panel when i select the different radio buttons . I am using the rich faces tags in my jsf page. I know how we can achieve this using javascript. But my interest is to achieve this functionality using Ajax. Is it possible . can somebody suggest.
I am quite new to JSF. I have a query . I need to display two different panel when i select the different radio buttons . I am using the rich faces tags in my jsf page. I know how we can achieve this using javascript. But my interest is to achieve this functionality using Ajax. Is it possible . can somebody suggest.
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
please provide the sample code that you are trying.
I think you are not aware of reRender AJAX property. Do some google on it. this will surely help you.
I think you are not aware of reRender AJAX property. Do some google on it. this will surely help you.
The woods are lovely, dark and deep, But I have promises to keep; And miles to go before I sleep, And miles to go before I sleep. - Robert Frost
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It is very possible. Simply use the "rendered=" attribute on the two panels in question and use EL expressions such as "#{myBean.radioSelection == 1}"/"#{myBean.radioSelection == 2}"
Use of AJAX support such as RichFaces reRender can reduce the need for full-page refresh, but the end result is the same.
Use of AJAX support such as RichFaces reRender can reduce the need for full-page refresh, but the end result is the same.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Mahendra Chowdary
Greenhorn
Posts: 25
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi ,
Could sombody provide me some sample code so that i can render component on the basis of ajax request
Thanks
Mahi
Could sombody provide me some sample code so that i can render component on the basis of ajax request
Thanks
Mahi
Mahendra Chowdary
Greenhorn
Posts: 25
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Please see my code ,
In the page i have,
<h:selectOneRadio id="Internalradioselect">
<f:selectItem id="InternalPerson" itemLabel="Person" itemValue="11">
<a:support event="onselect" reRender="panel1" action="#{addcontact.firstRadioChecked}" ></a:support>
</f:selectItem>
<f:selectItem id="InternalDistributionList" itemLabel="DistributionList" itemValue="22">
<a:support event="onselect" reRender="panel2" action="#{addcontact.secondRadioChecked}" ></a:support>
</f:selectItem>
</h:selectOneRadio>
<rich:panel id="panel1" rendered="#{addcontact.firstRadioChecked}">
Welcome to Panel 1
</rich:panel>
<rich:panel id="panel2" rendered="#{addcontact.secondRadioChecked}">
Welcome to Panel 2
</rich:panel>
In the java file i have
private Boolean firstRadioChecked = false;
private Boolean secondRadioChecked = false;
public Boolean getFirstRadioChecked() {
firstRadioChecked = true;
return firstRadioChecked;
}
public void setFirstRadioChecked(Boolean firstRadioChecked) {
this.firstRadioChecked = firstRadioChecked;
}
public Boolean getSecondRadioChecked() {
secondRadioChecked = true;
return secondRadioChecked;
}
public void setSecondRadioChecked(Boolean secondRadioChecked) {
this.secondRadioChecked = secondRadioChecked;
}
But while viewing on the page i am getting the following exception ..
javax.el.PropertyNotFoundException: /addcontact.xhtml @101,73 rendered="#{addcontact.firstRadioChecked}": Property 'firstRadioChecked' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_1
Please suggest
Thanks
Baziaz
In the page i have,
<h:selectOneRadio id="Internalradioselect">
<f:selectItem id="InternalPerson" itemLabel="Person" itemValue="11">
<a:support event="onselect" reRender="panel1" action="#{addcontact.firstRadioChecked}" ></a:support>
</f:selectItem>
<f:selectItem id="InternalDistributionList" itemLabel="DistributionList" itemValue="22">
<a:support event="onselect" reRender="panel2" action="#{addcontact.secondRadioChecked}" ></a:support>
</f:selectItem>
</h:selectOneRadio>
<rich:panel id="panel1" rendered="#{addcontact.firstRadioChecked}">
Welcome to Panel 1
</rich:panel>
<rich:panel id="panel2" rendered="#{addcontact.secondRadioChecked}">
Welcome to Panel 2
</rich:panel>
In the java file i have
private Boolean firstRadioChecked = false;
private Boolean secondRadioChecked = false;
public Boolean getFirstRadioChecked() {
firstRadioChecked = true;
return firstRadioChecked;
}
public void setFirstRadioChecked(Boolean firstRadioChecked) {
this.firstRadioChecked = firstRadioChecked;
}
public Boolean getSecondRadioChecked() {
secondRadioChecked = true;
return secondRadioChecked;
}
public void setSecondRadioChecked(Boolean secondRadioChecked) {
this.secondRadioChecked = secondRadioChecked;
}
But while viewing on the page i am getting the following exception ..
javax.el.PropertyNotFoundException: /addcontact.xhtml @101,73 rendered="#{addcontact.firstRadioChecked}": Property 'firstRadioChecked' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_1
Please suggest
Thanks
Baziaz
Mahendra Chowdary
Greenhorn
Posts: 25
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
When i try to run the page
the methods in the bean class are getting executed even before i perform an action like selecting a button on the page .
Can somebody please look into this .
Thanks
the methods in the bean class are getting executed even before i perform an action like selecting a button on the page .
Can somebody please look into this .
Thanks
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I presume you solved your first problem since you now tell us that you have been able to view the page?
In you java code you do this
So you getter method always return true and always sets the property in question as selected. Why?!? What is the logic here? Shouldn't the getter only get the property and setter set it when needed?
In you java code you do this
So you getter method always return true and always sets the property in question as selected. Why?!? What is the logic here? Shouldn't the getter only get the property and setter set it when needed?
Mahendra Chowdary
Greenhorn
Posts: 25
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I will call this function only when i select a particular radio button
Now , i am having another problem ,,
All the methods in my bean are getting executed without performing an action
Now , i am having another problem ,,
All the methods in my bean are getting executed without performing an action

Ilari Moilanen
Ranch Hand
Posts: 199
posted 15 years ago
So, as a simplification, the getters are being called when the form is viewed and setters are being called when the form is sent to server. Of course AJAX calls can make other getter and setter calls but the general rule still applies.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I see. So your real problem is that you do not understand basic concepts of JSF framework. Your form is sending the values to the bean when the forms is sent BUT the initial values of the inputs in the form ALSO come from the backing bean. That is why all the getters of the properties present in the form are being executed when the form is viewed! So if you think that the getters are only being executed when you call them yourself you are wrong.Go Green wrote:I will call this function only when i select a particular radio button
Now , i am having another problem ,,
All the methods in my bean are getting executed without performing an action
So, as a simplification, the getters are being called when the form is viewed and setters are being called when the form is sent to server. Of course AJAX calls can make other getter and setter calls but the general rule still applies.
Mahendra Chowdary
Greenhorn
Posts: 25
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
So ,
How should i modify my code so as to satisfy the following requirement.
I need to display different panels when i select different radio buttons in the page .
How should i modify my code so as to satisfy the following requirement.
I need to display different panels when i select different radio buttons in the page .
Mahendra Chowdary
Greenhorn
Posts: 25
Ilari Moilanen
Ranch Hand
Posts: 199
posted 15 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well, first of all fix your java code so that the getters behave as they should be and only return the values.
And if you need to show one of the panels initially you can change the initialization for example to this
or do something similar.
But what comes to you ajax code I can not help you there. Sorry. I am not familiar with Rich Faces tags.
And if you need to show one of the panels initially you can change the initialization for example to this
or do something similar.
But what comes to you ajax code I can not help you there. Sorry. I am not familiar with Rich Faces tags.
| My honeysuckle is blooming this year! Now to fertilize this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











