how to get managed bean property value inside javascript [duplicate]


This question already has an answer here:

<ul><li> <a href="/questions/14709014/how-do-i-pass-jsf-managed-bean-properties-to-a-javascript-function" dir="ltr" rel="nofollow">How do I pass JSF managed bean properties to a JavaScript function?</a> <span class="question-originals-answer-count"> 3 answers </span> </li> </ul>

Can anyone tell me how to get the managed bean property value inside the javascript method

something like

function fonction1() { var variable = "#{myBean.property}"; }


You can like this:

<h:inputText id="propertyId" value="#{myBean.property}" style="display:none"/>

and access it like this (note that if its inside a form you might need to add the form prefix)

alert($('#propertyId').val()); // or alert($('#myFormId\\:propertyId').val());


I guess you want it to be updated to the current value inside the bean. You can't! You can only add it to javascript during load time. If you want it to be updated you will have to do ajax calls to fetch the current value.


  • how to create selectAll checkbox in JSF-2
  • How to group headers of PrimeFaces dataTable with dynamic columns
  • After refresh I get old values in my page
  • Array PHP. How to get deep of element in array
  • Conditional display of p:overlayPanel
  • How to set timezone in jquery countdown timer
  • how to skip an index in a tuple result from a sql query
  • ADF actionListener doesn't fire in table in a popup
  • Getting street name from Address/Location object in Android
  • How do I change link-text in Wicket?
  • JSF 2.1 SelectOneMenu toggling automatically to init values
  • How to make JSF validator, valueChangeListener and actionListener be called once but not multiple ti
  • Download the source code in html of a form generated with angularjs
  • Redux-Form : How to mock formValueSelector in Jest
  • Add a pause/interval to every iteration in a FOR LOOP
  • how to get managed bean property value inside javascript [duplicate]
  • Why does Eclipse not deploy dependency to Glassfish?
  • Unable to compile this class for JSP
  • JSF reading dynamic input element in a managed bean
  • JSF 1.2 : Not able to retrieve bean values in xhtml page
  • How to detect change in form if added a new row in prime faces datatable
  • Sightly jstl c:set analog
  • What is the scope of Matlab's import function?
  • Referencing a CDI Bean in a non managed CDI Bean
  • Disable validator via ajax
  • Exclude field from a form in JSF
  • Target Unreachable, identifier 'demoBean' resolved to null [duplicate]
  • What is the JSF behaviour, if you bind the same backing bean property to two input fields in the sam
  • Database structure design with variable amounts of fields
  • How do I fake an specific browser client when using Java's Net library?
  • HTML download movie download link
  • How to get a value (ex: baseURL) in every Karate feature?
  • Updating server-side rendering client-side
  • How to set the response of a form post action to a iframe source?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal