Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

java - JSF: when disable component, its value does not make into the request map parameter. Is there a workaround?

I have a drop down list p:selectonemenu and a checkbox p:selectbooleancheckbox, when I select the checkbox, I want to set the selectonemenu to a specific value. And I dont want the user to change it, so I set selectonemenu disabled attribute to true. However, when it is disabled, its value does not appear inside the request parameter map, when I do facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap(), and I need its value to this map. Is there a way to get around this?

I writing a font-end to a legacy Servlet system, where they use request map parameters to obtain form attribute value.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As Adrian Mitev pointed out in a comment, disabling the selectBooleanCheckbox component will mean it will not post its value on a form submit.

What you can do however is have a hidden input field where you can set the value to the same managed bean property as the checkbox.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...