1

Based on the value of the inputHidden field, certain functionality should be performed on the javascript side.

<h:inputHidden id="onlyCaseSensitive" value="#{testBean.isPageAllowed()}"/> 

Afer the javascript is executed, the application throws an error Property not qritable Illegal Syntax for Set Operation

2 Answers2

1

Value of your h:inputHidde should point to the property of backing bean with getter and setter. So, probably when you submit your page there is a problem accessing setter field.

partlov
  • 13,789
  • 6
  • 63
  • 82
1

the application throws an error Property not writable Illegal Syntax for Set Operation

Your EL expression #{} is invalid. It must evaluate as a value expression, not as a method expression. It isn't possible to perform a setter method call on the given method expression, while that's required when the JSF form is to be submitted. You need to remove the is prefix and those parentheses to make it a valid value expression.

<h:inputHidden id="onlyCaseSensitive" value="#{testBean.pageAllowed}"/> 

This requires a public boolean isPageAllowed() getter method and a public void setPageAllowed(boolean pageAllowed) setter method.


If you actually only need to use the JSF managed bean property as a JavaScript variable, then you shouldn't be rendering it as a hidden input at all, but just let JSF render a fullworthy JavaScript variable without the need to mess with hidden inputs and HTML DOM traversal.

E.g.

<script>
    var onlyCaseSensitive = #{testBean.pageAllowed};
</script>

This will end up in the JSF generated HTML output like as follows (rightclick page and do View Source to see it):

<script>
    var onlyCaseSensitive = true;
</script>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • How can we access this field in javascript? $('#inputText').live("click focus", function(e) { if($('#inpText').val()== onlyCaseSensitive){ – user1978406 Feb 01 '13 at 17:47
  • Just look in the generated HTML source for the right element ID. See also http://stackoverflow.com/questions/7927716/how-to-select-primefaces-ui-or-jsf-components-using-jquery/7928290#7928290 – BalusC Feb 01 '13 at 17:51
  • and if I need to pass 2 arguments to isPageAllowed ? – WoutVanAertTheBest Jan 19 '15 at 14:09