JSF:当禁用组件时,它的值不进入请求映射参数.有解决方法吗? [英] JSF: when disable component, its value does not make into the request map parameter. Is there a workaround?

查看:19
本文介绍了JSF:当禁用组件时,它的值不进入请求映射参数.有解决方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表p:selectonemenu 和一个复选框p:selectbooleancheckbox,当我选中复选框时,我想设置selectonemenu 到特定值.而且我不希望用户更改它,所以我将 selectonemenu disabled 属性设置为 true.但是,当它被禁用时,它的值不会出现在请求参数映射中,当我执行 facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap() 时,我需要它的值到这个映射.有没有办法解决这个问题?

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?

我为遗留 Servlet 系统编写了一个字体端,在那里他们使用请求映射参数来获取表单属性值.

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

推荐答案

正如 Adrian Mitev 在评论中指出的那样,禁用 selectBooleanCheckbox 组件将意味着它不会在表单提交中发布其值.

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

然而,您可以做的是有一个隐藏的输入字段,您可以在其中将值设置为与复选框相同的托管 bean 属性.

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}" />

当复选框被禁用时,您可以使用 javascript 设置此隐藏输入的值.

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

这篇关于JSF:当禁用组件时,它的值不进入请求映射参数.有解决方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆