gpt4 book ai didi

jsf - 使用请求参数打开详细 View

转载 作者:行者123 更新时间:2023-12-04 14:14:31 24 4
gpt4 key购买 nike

我使用 myfaces 和 richfaces 创建了一个简单的主/细节。通过单击rich:dataTable 中的h:commandLink,用户可以打开详细信息 View 并编辑实体。

现在我想创建一个允许用户直接打开详细 View 的 URL。通常我会通过创建一个像/detail.jsp?id=12 这样的 URL 来实现这一点 - 我怎样才能用 JSF 实现呢?

最佳答案

您可以使用链接控件上的参数构建 URL:

    <h:outputLink value="reqscope.faces">
<f:param name="id" value="#{row.id}" />
<h:outputText value="link" />
</h:outputLink>

在目标页面上,您可以直接使用表达式语言或通过托管 bean 从参数映射中读取 id。

看法:
<f:view>
id= <h:outputText value="#{param['id']}" />
<br />
id= <h:outputText value="#{lookupBean.id}" />
</f:view>

bean 角,扁 bean :
public class LookupBean implements Serializable {

public String getId() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext extContext = context.getExternalContext();
Map<String, String> params = extContext.getRequestParameterMap();
return params.get("id");
}

}

faces-config.xml 声明:
<managed-bean>
<managed-bean-name>lookupBean</managed-bean-name>
<managed-bean-class>reqscope.LookupBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

关于jsf - 使用请求参数打开详细 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/450546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com