• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sende the previous response

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello coderanch,
i build a simple jsf-application which contains 2 input-fields and a submit-button (action leads to the page itself). The page prints the given parameters out.
What I am trying to implement is if you enter a specific value in the first input-field, the response you received before from the server, should be send again to you instead of the new calculated response...
example:

1. pagecall (called by user):
-> user enters "ABC" in field 1
-> user enters "123" in field 2
-> user submits

2. pagecall (called by submit):
-> JSF checks if value 1 is "DEF" - false
-> JSF prints out "ABC"
-> JSF prints out "123"
-> JSF set value of field 1 to "ABC"
-> JSF set value of field 2 to "123"
-> JSF saves the response
-> JSF send the response
-> user enters "DEF" in field 1
-> user enters "456" in field 2
-> user submits

3. pagecall (called by submit):
-> JSF checks if value 1 is "DEF" - true
=> skips calculating, setting values and so on and load last saved response (so the value of field 1 is not "DEF" but "ABC")
-> JSF send the response

is it even possible?

i tried it by adding phaselisteners and rewriting GET and SET-parameters (but the framework does not allow this)...
do i need to implement an own lifecycle-class or something like that?

kind regards
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JSF the more complicated your code, the more wrong it is. JSF is designed to make it easy to work with POJOs with a minimum of platform-specific coding. For projects like yours, in fact, that minimum is 0.

JSF is not like your typical "submit a form" web framework. JSF is based on the idea that people submit a form, get back error messages, and keep re-submitting the form until all the data is valid and can be processed, at which point you (usually) advance to some other page. This cycle of submits is a mechanism known as "postback".

JSF is also a very pure implementation of the Model/View/Controller paradigm where the Controllers are usually already supplied for you and operate transparently. Thus, you provide a View Template (".xhtml") and a Model (backing bean, also known as Managed Bean) and the Controllers are the FacesServlet and the JSF tag element processors. You bind the View to the Model using Expression Language (EL) expressions. Once you have done that, JSF will automatically format and populate the displayed View (web page) using the property values it finds (via "get" methods) in the Backing Bean, and conversely, when you submit, the View (Form) values that are submitted are passed back to JSF, which validates them, updates the Backing Bean values (using "set" methods) - if and only if all incoming data values are determined valid, and then, once the bean has been updated, the action method is invoked where the code that processes these values is located as well as the code that indicates where to navigate once the processing is done.
 
Mark Schneider
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mhh i think you misunderstood what i want to do.
I know the basics, but i want to interrupt the lifecycle... i "solved" the problem with the following code (which does not do what i want -resending previous response- but works all in all fine in the whole context). It just skips the "apply request values" and following parts and render the response directly (quick'n'dirty code):


This is not an optimum. If anybody got ideas for my problem, please post it.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want the View to render a given value, just update the Model in your Action method and the normal Render Response will do the rest. There's no need for platform-specific code to do that.

reply
    Bookmark Topic Watch Topic
  • New Topic