【发布时间】:2013-12-01 17:46:49
【问题描述】:
我正在使用 primefaces 4.0 和 jsf 2.0 开发一个 Java Web 应用程序。 我有一个文本标签,它是文本框。当用户处于编辑模式,并且想要修改特定文本框的值时,当用户在文本框中输入新值时,文本框的旧值应显示在右侧。所以我添加了一个在加载时呈现错误的输出文本。我想在用户单击文本框(id="customer_customername")时触发此输出文本(id="test")。所以渲染应该更改为相等。谁能告诉我该怎么做?在我的后端,我有一个接口及其实现、dao 和服务。
<h:panelGrid id="detail1" columns="2" styleClass="grid" columnClasses="label,value">
<h:outputText value="#{customermsgs['customer.customername.title']}:" />
<h:inputText id="customer_customername" value="# {CustomerComponent.customer.customername}" onclick="#{CustomerComponent.customername}" label="customer_customername">
<f:ajax render="detail1" />
</h:inputText>
<h:outputText id="test" value="#{CustomerComponent.customer.customername}" rendered="#{CustomerComponent.visible}"/>
</h:panelGrid>
public class CustomerComponentImpl implements CustomerComponent {
/**
* Data type variable that provides CRUD operations for Customer entities
*
*/
private boolean visible=false;
private String customername;
public String getCustomername() {
return customername;
}
public void setCustomername(String customername) {
setVisible(true);
this.customername = customername;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
//some codes goes here.
注意:我也在我的界面中实现了该方法。
onclick 事件不起作用。看起来它不会触发!有人可以帮忙吗?
【问题讨论】:
标签: jsf jsf-2 primefaces