部分刷新的面板中有条件隐藏的编辑框 [英] Conditionally hidden edit box in a partially refreshed panel

查看:23
本文介绍了部分刷新的面板中有条件隐藏的编辑框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的自定义控件由面板内的多个组合框和文本输入框组成.组合框的值相互依赖,因此当一个组合框发生变化时,会在面板上执行部分刷新以刷新其他组合框的值.

My custom control consists of a number of combo boxes and text input boxes within a panel. The combo box values depend on one another, so when a combo box is changed, a partial refresh is executed on the panel to refresh the values of the other combo boxes.

其中一个文本输入框也依赖于其中一个组合框 - 假设组合框标题是您有什么特殊要求吗?"并且值为是"和否".如果值为No",则 special_requirements 文本框被隐藏,并在 querySaveDocument 事件中作为N/A"保存到文档中.如果值为是",则显示 special_requirements 文本框,用户必须填写它,并保存他们的输入.

One of the text input boxes is also dependent on one of the combo boxes - let's say the combo box title is "Do you have any special requirements?" and the values are "Yes" and "No". If the value is "No" then the special_requirements text box is hidden, and saved as "N/A" to the document in a querySaveDocument event. If the value is "Yes" then the special_requirements text box is shown, and the user must fill it out, and their input is saved.

我一直遇到的问题是,如果我计算文本框的可见"属性的值,那么它会被适当地显示/隐藏,但是每当面板刷新时,任何用户输入都会被清除 - 例如用户选择是",输入一些文本,然后更改导致部分刷新的另一个组合框 - 文本框仍显示,但现在为空.

The problem I've been having is that if I compute the value of the "Visible" property of the text box, then it is shown/hidden appropriately, but any user input is cleared whenever the panel is refreshed - eg the user selects "Yes", inputs some text, then changes another of the combo boxes which causes a partial refresh - the text box is still shown, but is now empty.

目前我正在使用一种解决方法,而不是计算Visible"属性,而是计算 CSS 样式,在不需要文本框时将其设置为隐藏.然而,这意味着即使在组合框中选择否",用户也可以输入它,因此它不是理想的解决方案.有没有办法在刷新之间保留用户以前的输入,并在使用可见"属性将组合框选项从是"更改为否"时将其删除?

Currently I am using a workaround where instead of computing the "Visible" property, I compute the CSS style, setting it to hidden when the text box is not required. However, this means a user could input to it despite selecting "No" in the combo box, so it is not an ideal solution. Is there are a way to preserve the user's previous input between refreshes, and remove it if the combo box option is changed from "Yes" to "No" using the "Visible" property?

推荐答案

假设 Naveens 示例与您的示例存在相同的问题,那么 JSF 生命周期存在一个简单的问题:如果在 更新模型期间组件不可见 阶段,提交的内容没有被应用并丢失.

Assuming that Naveens example is the same problem like yours you have a simple problem with the JSF lifecycle: If a component is not visible during the Update Model Phase, the submitted content is not applied and gets lost.

只需将渲染属性更改为:

Just change the rendering property to this:

<xp:this.rendered>
   <![CDATA[#{javascript:
      if( view.isRenderingPhase() ){
         return getComponent("comboBox1").getValue() == "Yes"
      }else{
         return true;
      }
   }]]>
</xp:this.rendered>

这篇关于部分刷新的面板中有条件隐藏的编辑框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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