How to Pass Jsf Bean variable value to Jquery/JavaScript? -
this question has answer here:
- how select jsf components using jquery? 3 answers
i have java script code call on page page jquery
<script> function initreportexplr() { alert(jquery('#inputvalues').val()); } $(document).ready(function() { initreportexplr(); }); </script> and component using
<h:inputtext id="inputvalues" value="#{reportsbean.birtserverinformation}"/> and inside method initializing variable
public string getbirtserverinformation() { stringbuilder birtinfo = new stringbuilder(); birtinfo.append(constants.birt_server_url); birtinfo.append(","); birtinfo.append(constants.birt_server_port); birtinfo.append(","); birtinfo.append(constants.birt_user_name); birtinfo.append(","); birtinfo.append(constants.birt_password); birtserverinformation = birtinfo.tostring(); return birtserverinformation; } but getting undefined when trying print value code alert(jquery('#inputvalues').val());
as mentioned @geinmachi 1 solution of jquery is
jquery('#contentform\\:reportsform1\\:inputvalues').val(); and way through javascript is
document.getelementbyid("contentform:reportsform1:inputvalues").value;
Comments
Post a Comment