English 中文(简体)
有条件展示共同基金组成部分
原标题:Conditionally displaying JSF components

First, I am new to Java EE, came from a strong ASP .NET development background. I have gone through the net, and I might miss this but it seems like there is no simple and straight-to-the-point tutorials on how I could connect backing bean class to a JSF components.

一个很好的例子就是这样,目前,我正试图建立一个联合论坛的网页,该网页有一套像菜单和一套表格这样的链接。 我计划做的是,在点击某一环节时,将提供一种特殊的形式。

In ASP. NET,我可以轻易检索这个要素,然后确定可展示的属性。 我很想知道,在联合武装部队中,这样做是否容易(甚至有办法)。

表格已经放在网页上,只是确定“发送者”在我点击某一环节时的真实性。

最佳回答

是的,使用<条码>。

<h:form rendered="#{some boolean condition}">

通常,你会将其与模型挂钩,而不是让模型 gr碎成分,加以操纵。

E.g.

<h:form rendered="#{bean.booleanValue}" />
<h:form rendered="#{bean.intValue gt 10}" />
<h:form rendered="#{bean.objectValue eq null}" />
<h:form rendered="#{bean.stringValue ne  someValue }" />
<h:form rendered="#{not empty bean.collectionValue}" />
<h:form rendered="#{not bean.booleanValue and bean.intValue ne 0}" />
<h:form rendered="#{bean.enumValue eq  ONE  or bean.enumValue eq  TWO }" />

Note the importance of keyword based EL营运人gt,ge ,lt und >,>>=<= andlt; as anglecode>< and >> are reservationss in XML. See also this related Q&A: 放下X超文本:内容必须包含信息完备的特性数据或标记

As to your specific use case, let s assume that the link is passing a parameter like below:

<a href="page.xhtml?form=1">link</a>

之后,你可以显示如下表格:

<h:form rendered="#{param.form eq  1 }">

<<>(#{param}>系指代表请求参数的<代码>Map的隐含EL物体

See also:

问题回答

除以前的职位外,您还可以担任其他职务。

<h:form rendered="#{!bean.boolvalue}" />
<h:form rendered="#{bean.textvalue ==  value }" />

Jsf 2.0

我们可以提供形式的组成部分,因为我们将利用已作出的属性。

This attribute takes true/false. If the expression evaluates to a true then the specified component will be rendered otherwise it wont render in the screen.

具体地说,我想给某个情况提供一个子。

<p:commandButton id="addCommentsBtn"
    value="Add Comments" title="Add Comments"
    rendered="#{backingBean.booleanResultOrVariable}">
</p:commandButton>




相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签