Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My JSF form won't submit

 
Stamin Adrian
Ranch Hand
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add <f:view> before <h:form> and end it with </f:view> after the </h:form> tag..
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
Primo Esteria
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic