aspose file tools*
The moose likes JSF and the fly likes My JSF form won't submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "My JSF form won Watch "My JSF form won New topic
Author

My JSF form won't submit

Stamin Adrian
Ranch Hand

Joined: Dec 21, 2012
Posts: 34

I've been struggling with this problem for too long.I really can't tell what is wrong with the code.
This is my JSF registerForm.xhtml which is included in the index.xhtml.

You are probably wondering why I used onclick instead of action.Well, action does nothing, I tryed debugging.
It never goes in the method.With onclick it goes in the method, but all my properties are null.
This is my bean:

I made an account on this forum just to post this.Please help me!I would be eternally gratefull.Please excuse my bad english.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

Hi Adrian, and welcome to JavaRanch!

Wow, everyone is suddenly asking about PrimeFaces. I'll have to give it a try someday. I think if you put <h:messages /> or <p:messages /> somewhere in your page, it might give you information about why the form values aren't getting to your setters. I'd also change the command button so it had an action again instead of the onclick (or actionListener since your method has a void return value), but take away the parentheses:



In addition to the Java debugger, you can use browser tools to help figure out what's going on. I often rely on the Net tab of Firebug for Firefox, which shows all the requests and responses as they are sent and received. I believe Chrome has similar tools. And IE ... well, don't use IE for development. Get things basically working first, then worry about supporting IE.
Stamin Adrian
Ranch Hand

Joined: Dec 21, 2012
Posts: 34

Thanks for responding so fast.

I tryed <p:message> <p:messages> and the facelets ones with h: . Nothing shows up. With actionListener it never prints out my values in the console.The console always shows this info


It doesn't say anything else.I really think what i've done is basic.I'm starting to hate JSF.I need to finish this project for a class i'm taking.I even tried simpler forms.Tried without the table and with both primefaces and jsf.The button does nothing with action or actionListener.It only works with onclick but values are null.I don't know why <h:message> or <h:messages> won't pop up.The Glassfish log is useless.Doesn't say anything.Could that warning be relevant? I'm afraid if I start the project from scratch I will run in the same problems. Can the composition thing afect my submit? The composition is rendered with ajax.Any ideas? They would be much apreciated!
Stamin Adrian
Ranch Hand

Joined: Dec 21, 2012
Posts: 34

I realized the following after hours of research.It seems that <ui:include src="myComposition.xhtml"> actually doesn't change the xhtml code.So html doesn't know i'm pressing the submit. Is there someway to include myRegisterForm.xhtml in the index.xhtml and actually change the code dinamicaly. How do you do this with jsf?
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

Add <f:view> before <h:form> and end it with </f:view> after the </h:form> tag..
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16141
    
  21



This is poor practice. If you want to control whether the submit action fires (and you didn't supply an action method reference), you would code something like "onclick="return myJSFunction()". What you have coded appears to be bad EL returning a constant unknown boolean value to a javascript event handler.

I also recommend using JSF grid formatting instead of raw HTML table tags, but that wouldn't affect functionality.


Customer surveys are for companies who didn't pay proper attention to begin with.
Primo Esteria
Greenhorn

Joined: Aug 31, 2011
Posts: 3
The value of onclick attribute of <p:commandButton /> is suppose to be a JavaScript code that is executed when you click on the button. Use either action or actionListener.


http://kahimyang.info
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My JSF form won't submit