EL语句在c:forEach循环中的视图构建时间内会发生什么。
<c:forEach var="v" values="#{bean.values}">
<p:inputText value="#{v.name}" />
</c:forEach>
class Bean {
public List<Pojo> getValues();
}
class Pojo {
public void setName (String);
public String getName();
}
Run Code Online (Sandbox Code Playgroud)
此代码将如何评估渲染?至:
<p:inputText value="John Smith">
Run Code Online (Sandbox Code Playgroud)
要么
<p:inputText value="#{pojo.name}" >
Run Code Online (Sandbox Code Playgroud) 您好,在我的项目中,我需要可视化货币价值,就我的 f:convertNumber 而言
我使用固定的货币符号;一切都很好,但是当我尝试使用如下表达语言获取符号时:
<h:outputText value="#{rowItem.value}">
<f:convertNumber currencySymbol="#{rowItem.getCurrencySymbol()}" groupingUsed="true" maxFractionDigits="2" type="currency" />
</h:outputText>
Run Code Online (Sandbox Code Playgroud)
就像没有调用 getCurrencySymbol 方法一样,我确信我缺少一些东西。
使用 Facelets 并编写一些 XHTML,我无法弄清楚如何创建一个元素,然后在稍后添加属性,例如在 xslt 中,如果您想有条件地添加一个属性:
<xsl:element name="div">
<xsl:attribute name="style">color:blue;</xsl:attribute>
</xsl:element>
Run Code Online (Sandbox Code Playgroud)
谷歌给出了一些类似于 JSP taglib 的例子
<jsp:element name="div">
<jsp:attribute name=".">...</jsp:attribute>
</jsp:element>
Run Code Online (Sandbox Code Playgroud)
该库未作为 Facelets 中的标准提供,并且搜索包含的库的文档不会显示任何明显的信息。
我有一个动态生成的数据表,就像这样
DataTable dataTable = new DataTable();
dataTable.setValue(relatorioVOList);
dataTable.setVar("rVO");
Column checkBoxColumn = new Column();
checkBoxColumn.getChildren().add(this.viewComponentBuilder.createExpressionTextWithLink("#{rVO.iRelatorio}","#{rVO.nNome}"));
dataTable.getColumns().add(checkBoxColumn);
public HtmlForm createExpressionTextWithLink(String iRelatorioExpressionValue, String valueExpressionValue) {
HtmlForm form = new HtmlForm();
HtmlCommandLink link = new HtmlCommandLink();
//config
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ExpressionFactory ef = application.getExpressionFactory();
ELContext elc = context.getELContext();
//value that is the reports name
ValueExpression nameValueExp = ef.createValueExpression(elc, valueExpressionValue, Object.class);
link.setValueExpression("value", nameValueExp);
//action that goes to method teste when link is clicked
MethodExpression methodExpression = createMethodExpression("#{componenteC.teste(rVO.iRelatorio)}", String.class, Integer.class);
link.setActionExpression(methodExpression); …Run Code Online (Sandbox Code Playgroud) Mojarra 2.1.
我检查public void execute(FacesContext facesContext) throws FacesException了班上的方法com.sun.faces.lifecycle.RestoreViewPhase.现在,一旦视图通过invokation恢复, viewRoot = viewHandler.restoreView(facesContext, viewId);我们就可以获得前一个请求中的竞争树(如果它是回发).
我检查了那棵树(手动迭代children调试器中组件的属性)并发现复合组件,声明如下:
<h:panelGroup rendered="#{bean.id == 1}">
<utils:dropDownListFilterItem />
</h:panelGroup>
<h:panelGroup rendered="#{bean.id == 2}">
<utils:dateFilterItem />
</h:panelGroup>
<h:panelGroup rendered="#{bean.id == 3}">
<utils:fieldFilterItem />
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
都在那棵树里.尽管#{bean.id}被评估为2 ,但它很高兴.我发现唯一的<utils:dateFilterItem />实例将在树中.
所以,我的问题是renderedMojarra 如何处理属性?属性是否会影响唯一的渲染响应阶段?
JSF Converter似乎是在xhtml页面上的任何其他托管bean之前调用的.它甚至可以rendered=false在h:selectOneMenu组件上创建.
我已经创建了3个托管bean来测试初始化序列,并且托管bean按顺序初始化它们出现在xhtml中,但在它们之前,尽管是最后一个创建了JSF转换器.
形成
<h:form>
<h:inputText value="#{creationTime1.string1}"/>
<h:inputText value="#{creationTime3.string3}"/>
<h:inputText value="#{creationTime2.string2}"/>
<h:selectOneMenu value="#{creationTime1.competitor}" rendered="false" converter="#{testConverter}" >
<f:selectItem itemValue="#{null}" itemLabel="#{msg.none}" />
<f:selectItems value="#{creationTime1.competitorList}" var="competitor" itemValue="#{competitor}"
itemLabel="#{competitor.idCompetitor}"/>
</h:selectOneMenu>
<h:commandButton value="GO" action="#{creationTime1.submit}"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
变流器
@Named(value = "testConverter")
@ViewScoped
public class TestConverter implements Converter, Serializable {
@PostConstruct
private void init() {
System.out.println(System.currentTimeMillis() + " || TestConverter init");
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
...
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据 GUI 中其他选项的一些选择,在primefaces 中填充一些带有内容的下拉菜单。这是我正在尝试做的一个简化示例:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" >
<h:head>
<title>Test</title>
</h:head>
<h:body>
<h:form>
<c:set var="options" value="#{['1','2','3']}" />
<c:set var="currentValue" value="#{3}" />
<h:outputText value="${options}" />
<ui:repeat var="r" value="#{options}">
<h:outputText value="#{r}" />
</ui:repeat>
<c:set var="currentValue" value="#{currentValue}" />
<p:selectOneMenu id="selectValue"
value="${currentValue}"
class="pFieldSet_Template_Input200 r10">
<p:ajax event="change" />
<ui:repeat var="r" value="#{options}">
<f:selectItem itemLabel="Choice #{r} (20180101)" itemValue="#{r}" />
</ui:repeat>
</p:selectOneMenu>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我访问该页面时,它显示 [1, 2, 3]123 和一个空的 selectOneMenu。我本来希望 selectOneMenu 也包含这些选择。迭代显然适用于上述情况,所以我不知道为什么它不显示菜单中的选项。我究竟做错了什么?
经历了这些优秀的帖子:
在JavaEE6教程的中途,我仍然有以下问题:
谢谢
我想添加动态输入字段.喜欢

PF关于如何添加这样的组件有一个很好的组成部分吗?
请给我一个关于如何开发它的提示,因为我现在还没有任何线索.
我非常感谢你的回答.
我的技术堆栈: