Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf and javascript

 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have 2 input box whereby the value will be set through javascript. However, im not able to get the update values from the input box.

My jsf code:


to get the value, i tried the following code:
my managed bean code:

when i print out the value for timeInputTxt and dateInputTxt, i get null values.

What have i done wrongly?

-thanks.
 
Ashraf Abu-Aisheh
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friend,

First, where is the action here??

I see the type is button, So there is no submit, therefor the code is still in the page and didn't arrive to the managed bean.

Second, if you did the submit in javascript and put the following code in the constructor of your managed bean; The values will be null because the setter method didn't accessed yet:
 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but if i set to submit, it is submitting the form.. which is what i dont want. I only want the button to trigger a javascript function.

the button will only trigger a javascript that will open up a calendar for the user to select the date and time. Upon selection, the selected date and time will be set to the respective textbox.

i have also tried to do
<a4j:commandButton id="DateBtn" onclick="getDateTime()" type="button" value="Get Date and Time" reRender="dateTxt,timeTxt"/>

but it doesn't work.

Anyone? thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic