File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes To Authors : About JSF lifecycle & JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To Authors : About JSF lifecycle & JS" Watch "To Authors : About JSF lifecycle & JS" New topic
Author

To Authors : About JSF lifecycle & JS

Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Hey Authors,

Here's my query:

The JSF standard Request Life cycles consist of phases which works perfectly fine in case of a simple flow.

But in case of where I have several validations/controls with logic in my UI page, I have to play around a lot to get things done, which seems too buggy at times.

Just to implement a "reset" functionality in page containing a required input field (with a required attribute ="true"), I have to play around a lot to get things done. Infact I noticed couple of JSF dons at java.sun suggesting me to open a new page everytime the user click the "reset" button to get this implemented, which sounds pretty odd.

Another scenario, in a page with a input date field (and a date validator associated to the field) and two radio buttons & based upon the selected radio button I just had to simply change the text label of the date Field. Now everytime I was trying to implement this the date validator was getting invoked, which wasn't necessary at that time.
Now I have solved or rather found the workaround for these issues, but for that either I have to tweaked the life cycle or have to used the javascript.

Now most pages in my application contains validation/ font end logic etc. and looking at the app now I wonder if I am really using JSF standard life cycle or playing with it

So what's your opinion about playing with the JSF's life cycle? (though JSF provides enough functionality/flexibility to do so)
and do you think using Javascript along with JSF is acceptable or rather a bad practice?
[ December 14, 2004: Message edited by: K Varun ]

- Varun
David Geary
Author
Ranch Hand

Joined: Apr 23, 2003
Posts: 45
For your date example, you want to suppress validation when you select a radio button. You can do that by setting selectOneRadio's immediate attribute to true.

The JSF lifecycle is very flexible. You can skip parts of it or all of it as you deem necessary. You can also selectively opt out of validation with immediate events. Of course, like any other power tool, you have to be careful.

Intelligent design of JSF components, such as a date picker, will almost always require some script. I try to only hit the server when I have a finished value to send to the server. If I'm trying to affect a change in the UI, I prefer scripts.


David Geary Sabreware, Inc<br /><a href="http://www.corejsf.com" target="_blank" rel="nofollow">http://www.corejsf.com</a><br /> <br />Author: Graphic Java Series, Advanced JavaServerPages, Core JSTL and Core JavaServer Faces
Basel Al-Mustafa
Greenhorn

Joined: Nov 27, 2004
Posts: 27
Hi,

Keep in mind that if the immediate attribute is set to true then the command is executed during the "Apply Request Values" phase.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Thanks David.

For your date example, you want to suppress validation when you select a radio button. You can do that by setting selectOneRadio's immediate attribute to true.

I used this approach only, followed by calling
facescontext.renderResponse() .. as without this the validation were being called.


Also, in your book you have mentioned about "debugging and logging" related to Apache tomcat.

Do you have any suggestions about how to enable it in the Websphere Studio Application Developer 5.1.2 ? I searched on it but couldn't find any useful information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To Authors : About JSF lifecycle & JS
 
Similar Threads
how can we update the Managed Bean data in Process Validation phase?
struts2 radio button validation
RADIO BUTTON WITH ROW IN DATA TABLE
Struts 1.1: html:radio issues
Can radio button input really be validated with Struts Validator?