JSF: when a component is disabled, its value is not included in the request map parameter. Is there a workaround?

I have a p:selectonemenu and a p:selectbooleancheckbox , when I check the box, I want to set selectonemenu to a specific value. And I do not want the user to change it, so I set the selectonemenu disabled attribute to true . However, when it is disabled, its value does not appear inside the query parameters map when I do facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap() , and I need its value for this map. Is there any way around this?

I write end-font in an outdated servlet system where they use request map parameters to get the value of a form attribute.

+6
source share
1 answer

As Adrian Mitev noted in a comment, disabling the selectBooleanCheckbox component means that he will not publish its value in the submit form.

However, you can have a hidden input field in which you can set the value for the same managed bean property as the check box.

 <h:inputHidden id="checkDisabled" value="#{managedBean.someValue}" /> 

Using javascript, you can set the value of this hidden input when the checkbox is disabled.

+8
source

Source: https://habr.com/ru/post/912450/


All Articles