dcsimg
Using javabeans properties as variable values in a javascript method.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   olivia_kyle
Posted On:   Thursday, October 16, 2003 07:17 AM

I would like to set up my JSP page with a textfield that contains an INITIAL value when the user arrives at the page. The value is taken from one of two different bean properties (bean#1 is called "accountNum"; bean#2 is called "account"). I would like to create a javascript method that pulls the property from bean#1 if the previous page visited was abc.jsp, or from bean#2 if the previous page visited was any other page. This is the method that I have now that doesn't seem to work (it gives me a syntax error for the 1st var declaration): function redirection(){ var acctNum1 = ; var acctNum2 = ; if (document.referrer == "abc.jsp") {return acctNum1;} else {return acctNum2;} } ]]>]]>    More>>

I would like to set up my JSP page with a textfield that contains an INITIAL value when the user arrives at the page. The value is taken from one of two different bean properties (bean#1 is called "accountNum"; bean#2 is called "account"). I would like to create a javascript method that pulls the property from bean#1 if the previous page visited was abc.jsp, or from bean#2 if the previous page visited was any other page.


This is the method that I have now that doesn't seem to work (it gives me a syntax error for the 1st var declaration):


			



Within my HTML form, my textfield is coded as follows:



			
		



However, using the method call for the 'value' doesn't seem to work; it merely places the text "javascript:redirection();" in the textfield.


Can someone help me? Thanks a million!!!

   <<Less

Re: Using javabeans properties as variable values in a javascript method.

Posted By:   Adrian_K  
Posted On:   Thursday, October 16, 2003 08:19 AM

You can try something like this:






Another event could be more suitable for yuor application needs.

Re: Using javabeans properties as variable values in a javascript method.

Posted By:   olivia_kyle  
Posted On:   Thursday, October 16, 2003 07:21 AM

I just read that javabean properties cannot be accessed in the client-side javascript methods. HOWEVER, I if the bean properties can be accessed directly in the 'value' attribute of the textfield, I think I should be able to set the bean getProperty code as a STRING in the javascript method (e.g., var acctNum1 = '';)


THIS DOESN'T WORK EITHER! :-( And I can't seem to get the method to be called in the 'value' attribute anway to test it! Oiy! Help!

About | Sitemap | Contact