hibernate - jsf 表单编辑值未反映在托管 bean 中
问题描述
我正在尝试编辑填充的表单,但它仅在单击命令按钮后将旧值发送到 managedBean。
概念概览:
每当我单击编辑时,我都有一个 outputText 和 inputText 字段,我将行的 id 发送到名为 EditBean 的托管 bean 并存储行的 id,如果 bean 中的 id 与将呈现 inputText 的行,否则将呈现 outputText,现在当我更改 inputText 字段中的值时,该行将使用旧值更新!
JSF 页面:
<h:form id="form">
<h:dataTable value ="#{profil.getProfils()}" var ="profil" class="table table-dark">
<h:column>
<f:facet name = "header">Login</f:facet>
<h:inputText value = "#{profil.login}" id="login" size = "10" rendered = "#{edit.id eq
profil.login}" class="form-control"/>
<h:outputText value = "#{profil.login}" rendered = "#{edit.id ne profil.login}" />
</h:column>
<h:column>
<f:facet name ="header">Edit</f:facet>
<h:commandButton id="edit" value="Edit" action="#{edit.setId(profil.login)}"
rendered ="#{edit.id ne profil.login}" class="btn btn-primary">
<f:ajax execute="@form" render="@form" />
</h:commandButton>
<h:commandButton id="save" value ="Save"
action="#{profil.updateProfil()}"
rendered = "#{edit.id eq profil.login}" class="btn btn-primary" >
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
轮廓豆:
@Entity
@Table(name="profil")
@ManagedBean(name="profil")
public class Profil implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String login;
public String updateProfil() {
ProfilDao dao = new ProfilDao();
dao.updateProfile(this);
EditBean eb = new EditBean();
eb.setId(null);
return "saved";
}
解决方案
推荐阅读
- logging - 值日志和审计有什么区别?
- python - 为什么我不能导入 selenium 的 webdriver?
- swift - 如何在另一个字符串中找到所有出现的字符串子集并将它们替换为其他字符串?(例如:表情替换)
- python - 如何访问 defaultdict 中命名元组列表的各个索引?
- c# - 标签助手字段编码错误
- java - 数组类型在 Getmapping 请求中返回 null
- php - 是否可以从 Oracle 视图中读取数据并将其插入 MYSQL 表中?
- pine-script - 如果当前价格是开盘价,我如何查看策略?
- python - 使用 R/Python 从 Web 下载数据的非硒方式
- php - 不断获取count():参数必须是数组或者实现了Countable的对象