JSF:动态变化形式 [英] JSF: Dynamically change form

查看:116
本文介绍了JSF:动态变化形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个动态变化的组件可见取决于其他组件的状态表。

I want to build a form that dynamically changes the components visible depending on the state of other components.

例如...有一些文本框和一些复选框,并且如果用户激活一个特定复选框,一束其它输入元件的应该出现

For example... There are some text boxes and some check boxes, and if the user activates a certain check box, a bunch of other input elements should appear.

我能做到这一点与JSF 2.0 +战斧或我再弄库这样做呢?我该怎么办呢?这不AJAX将无法正常工作,会这样吗?

Can I do this with JSF 2.0 + Tomahawk or do I have to get another library to do this? And how can I do it? This won't work without AJAX, will it?

在此先感谢!

推荐答案

Ajax是一种方便的方式来做到这一点,JSF 2.0自带的ajax捆绑。

Ajax is a convenient way to do this and JSF 2.0 comes with ajax bundled.

下面是一个例子:

<h:selectOneRadio value="#{a7.myCheckbox.state}">
      <f:selectItem itemLabel="#{bundle.yes}" itemValue="1"/>
      <f:selectItem itemLabel="#{bundle.no}" itemValue="0"/>
      <f:ajax render="uawGroup"/>
</h:selectOneRadio>

<h:panelGroup id="uawGroup" layout="block">
   <h:outputText value="#{bundle.wichmed}"
        rendered="#{a7.myCheckbox.state == 1}"/>
   <h:inputText value="#{}" id="myInput"
        rendered="#{a7.myCheckbox.state == 1}"/> 
</h:panelGroup>

H:当是 - 选项被点击 panelGroup中将呈现H:selectOneRadio (itemValue == 1)。最初,它是0(在豆A7集)。

The h:panelGroup will be rendered when "yes"-option is clicked in h:selectOneRadio (itemValue == 1). Initially it is 0 (set in the bean "a7").

H:panelGroup中作为包装,因为你只能更新与AJAX组件的页面( h在实际中呈现的outputText H:。inputText的最初不显示的)

The h:panelGroup acts as wrapper since you can only update components with ajax that are actually rendered on the page (h:outputText and h:inputText are initially not displayed).

这篇关于JSF:动态变化形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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