Simple form not working

UI Components for JSF
Post Reply
gschrade
Posts: 10
Joined: 23 Dec 2011, 22:23

23 Dec 2011, 22:35

I am not only new to PrimeFaces, but new to faces. I am trying to create a simple form. Here is the code:

Code: Select all

<h:form>	
			<h:outputText value="Response" />
			<p:selectOneRadio id="#{FormComponent.response}">  
	            <f:selectItem itemLabel="Yes" itemValue="yes" />  
	            <f:selectItem itemLabel="No" itemValue="no" />  
	        </p:selectOneRadio>
			<p:commandButton id="SubmitButton" value="Save" action="#{FormComponent.saveTest()}"/>
			
		</h:form>
FormComponent is the interface. Here is FormComponentImpl that implements FormComponent:

Code: Select all

private String response;
public String getResponse() {
		return response;
	}

	public void setResponse(String response) {
		this.response = response;
	}
Here is the saveTest method:

Code: Select all

public void saveTest(){
		System.out.println("++++++++++++++++++++++++++++++++++++++");		
System.out.println("householdFormId = "+getResponse());
	}
I am using core Spring. As soon as I load the xhtml, the form does not display the radio buttons, nor the submit button, and the form submits when it loads. It prints null for the response in the saveTest() method. Any help would be greatly appreciated.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

23 Dec 2011, 22:43

Please double check your code:

Code: Select all

<p:selectOneRadio id="#{FormComponent.response}">  
What should this do? Use the value attribute instead.


Just a tip: Also a good naming convention for beans is lower camel case. The first character should be lower case.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

gschrade
Posts: 10
Joined: 23 Dec 2011, 22:23

23 Dec 2011, 22:54

OK, I have made those changes. This is just a test to see if response is getting populated with a yes or no value. After making the changes the form does not submit by itself, but neither the radio buttons, nor the submit button appear on the page.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

23 Dec 2011, 23:19

Post your code again please - also the complete FormController.
Also consider that you have a h:head tag and the bean is also named with lower case then.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

gschrade
Posts: 10
Joined: 23 Dec 2011, 22:23

24 Dec 2011, 00:18

got it working with h:selectOneRadio

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests