wood burning stoves 2.0*
The moose likes JSF and the fly likes why is my javascript not working after migration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "why is my javascript not working after migration " Watch "why is my javascript not working after migration " New topic
Author

why is my javascript not working after migration

jyothi nalam
Greenhorn

Joined: Oct 25, 2006
Posts: 24
I have a radio button and a rich:calendar component. on select of a radio button the rich:calendar need to be updated.
We are migrating our application from richfaces 3.3 to richfaces 4, jsf 1.2 to jsf 2.
Following is my code that worked fine before migration.



Please help. i could not figure out what is wrong since i am new to jsf and richfaces and also not good with javascript.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

I'm not actually sure about the validity of the "render()" javascript function, but that's not something I usually do, since I've always used the a4j:support method to supply dynamic re-rendering. In RF4, that would probably mean adding an "f:ajax" sub-element to your radio button. And, as a general rule, I've found it simpler and safer to let AJAX update the Model (backing bean) and then re-render the control from the model than to meddle with the control values on the page.

Incidentally, the "language="javascript"" attribute on the script tag is deprecated as of HTML5.


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

Joined: Oct 25, 2006
Posts: 24
Tim Holloway wrote:I'm not actually sure about the validity of the "render()" javascript function, but that's not something I usually do, since I've always used the a4j:support method to supply dynamic re-rendering. In RF4, that would probably mean adding an "f:ajax" sub-element to your radio button. And, as a general rule, I've found it simpler and safer to let AJAX update the Model (backing bean) and then re-render the control from the model than to meddle with the control values on the page.

Incidentally, the "language="javascript"" attribute on the script tag is deprecated as of HTML5.


Thanks a lot for the reply Tim.

My application has two options. we can select the date range either through the radio buttons which have 30days(default), 60days etc options or directly set the date from the rich:calendar component.

When I have tried with ajax and backing bean, the radio buttons work fine and update the calendar dates. Following is my code:

But I am failing the other way, I could not set the calender directly, because when i click the search, the dates are reset to the dates selected by the radio button.

Please suggest. The examples that I saw online does not give much details about the javascript functions of the calendar component.

Thanks in advance.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

I'm at a loss, myself. I switched to the RichFaces calendar years ago. Tomahawk was fairly new when I used it, and back then I got scalped regularly.
jyothi nalam
Greenhorn

Joined: Oct 25, 2006
Posts: 24
I got it resolved. In my code previously, the setPoSelectedDateRange method assigns value to the dateTo and dateFrom calendar components. So this method is always called before submitting the search. So I separated the logic to set the calendar components and called that from the listener.

This is how, I was doing.


so poDatePlacedRange is just a setter which sets the variable poDatePlacedRange. and the listener method is the one that gets called whenever there is a change in radio button select.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why is my javascript not working after migration