How to Pass Jsf Bean variable value to Jquery/JavaScript? -


this question has answer here:

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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -