Topic
  • 2 replies
  • Latest Post - ‏2013-05-28T21:15:45Z by 6UGU_Susheel_Vadde
venugopal18
venugopal18
3 Posts

Pinned topic how to assign a javascript variable value to builder variable in portlet factory

‏2013-05-02T11:16:26Z |

hi ,

i have a requirement in my project like ,from javascript function iam getting  one value,this value i want to store in builder variable.

for this iam using the below statement in javascript function, but it is not working.

<% String jspvar="<script>document.writeln(javascriptVariable);</script>";

 webAppAccess.getVariables().setString("countRecords",jspvar);

%>

 

please help me how to solve this problem.

Thanks

venugopal

 

 

 

  • kevintap
    kevintap
    749 Posts

    Re: how to assign a javascript variable value to builder variable in portlet factory

    ‏2013-05-03T15:12:39Z  

    What you're trying to do here won't work.  The JSP code fragment that you have written will execute on the app server when the browser makes the request for this page.  At this point, you're executing code on the server and there is no client browser/javascript context.

    In order to set a model variable with the value of some javascript variable, the browser will need to submit a form to the server and pass the value to the server via the form.  You can use any of the various WEF action builders (Button, Link, HTML Event Action) to generate the necessary browser markup to submit a form to the server.  You would need to ensure that you have some javascript that runs in the browser to set the form values before it is submitted.

  • 6UGU_Susheel_Vadde
    6UGU_Susheel_Vadde
    9 Posts

    Re: how to assign a javascript variable value to builder variable in portlet factory

    ‏2013-05-28T21:15:45Z  
    • kevintap
    • ‏2013-05-03T15:12:39Z

    What you're trying to do here won't work.  The JSP code fragment that you have written will execute on the app server when the browser makes the request for this page.  At this point, you're executing code on the server and there is no client browser/javascript context.

    In order to set a model variable with the value of some javascript variable, the browser will need to submit a form to the server and pass the value to the server via the form.  You can use any of the various WEF action builders (Button, Link, HTML Event Action) to generate the necessary browser markup to submit a form to the server.  You would need to ensure that you have some javascript that runs in the browser to set the form values before it is submitted.

    In addition to kevintap information , you can use the hidden Input builder. Assign the value to that hidden input builder  using javascript by its name , and  reference that easily after submit in any of your actions and assign it to the variable.