File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setters not being called on bean when navigating away from JSP page

 
John Farrel
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have one session level object that is referenced by several wizard jsp pages, each page updating different values on the object. The pages are linked via 'next' and 'previous' buttons. The object is correctly updated when navigating between the pages. However, the last page of the wizard has a 'submit' button. The problem is, the setters for the data on the last page of the wizard are not being called when the submit button is pressed. (but they are when navigating to 'previous')

The only difference between the 'previous'. 'next' and 'submit' buttons is that the 'submit' button goes to a servlet, and the next and previous go to jsp pages.

I fiddled the html so that the submit also went to a jsp page, but it made no difference. I just can't get the last wizard page to store its changes if I click on submit.

Any help would be appreciated.

I am developing on Apache Tomcat 6.0.20.

John.


 
John Farrel
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok, I see what one of my problems is. I need a <setProperty property="*"> on the submit page as well. Is it possible to do this in code in a servlet?

My other problem is this... The spec for JSPs says it will not execute the setter for any value that has been set to "" or null. Why would this be a good thing? If a user sets a form value to empty, I need to know it.

The only solution I can think of to save this is to forward each Next, Previous and Submit through a servlet which uses reflection to go through all the parameters and manually set values and then forward to the 'real' next page. very annoying. Is there a better way?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Farrel wrote: Is there a better way?

as you said use servlet as a controller and java class as a model(for business logic) .

coming to your last page submit problem, I will give you a clue ok ?

the clue is *how you are storing the values to session from every page(submitting) ?*
 
John Farrel
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


For posterity...

Firstly, I didn't realise the <jsp:setProperty .... property="*"/> needs to go in every destination jsp file, including the submit jsps.
Secondly, the <jsp:setProperty ... property="*"> setting is garbage. It ignores any input set to empty string or null values.
Instead I replaced all the setProperty tags with some third party code do the same reflection trick, but one that does not ignore empty strings and null values.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're looking for best practice advice, submitting to a JSP is a big no-no. All submissions should be performed to a servlet in a modern, best-practice JSP.
 
John Farrel
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you're looking for best practice advice, submitting to a JSP is a big no-no. All submissions should be performed to a servlet in a modern, best-practice JSP.


Actually, I was and am. The jsp was just there to test a theory and has been replaced with a servlet.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Farrel wrote:The jsp was just there to test a theory and has been replaced with a servlet.


cool
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic