我想在循环中动态地向<p:tab>组件添加组件<p:wizard>.
我尝试使用<ui:repeat>内部和外部<p:wizard>组件.
<p:wizard>
<ui:repeat value="#{tabBean.tabs}" var="tab">
<p:tab title="#{tab.tabname}">
</ui:repeat>
</p:wizard>
Run Code Online (Sandbox Code Playgroud)
<ui:repeat value="#{tabBean.tabs}" var="tab">
<p:wizard>
<p:tab title="#{tab.tabname}">
</p:wizard>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
两种尝试均无效.我怎样才能达到我的要求?
我想通过使用<ui:repeat>和<p:dialog>使用创建动态对话框窗口<ui:include>.但是当我尝试下面的时候有一个例外.
main.xhtml
<p:outputPanel id="windowsPanel" layout="block" style="width:100%;">
<p:outputPanel rendered="#{mainView.dynamicWindows ne null}">
<ui:repeat var="item" value="#{mainView.dynamicWindows}">
<p:dialog binding="#{item.dialog}">
<ui:include src="#{item.includedWindowPath}" />
</p:dialog>
</ui:repeat>
</p:outputPanel>
</p:outputPanel>
Run Code Online (Sandbox Code Playgroud)
MainView.java
@ManagedBean(name = "mainView")
@SessionScoped
public class MainView extends BaseView {
private static final long serialVersionUID = -6291834350102049312L;
private List<Window> dynamicWindows;
@PostConstruct
public void init() {
fillWindows();
}
private void fillWindows() {
dynamicWindows = new ArrayList<Window>();
for (int i = 0; i < 3; i++) {
Window window = new Window("Header " …Run Code Online (Sandbox Code Playgroud) 我正在使用 jstl 进行小型测试。它不应该如何工作
这是小代码:
<c:set var="id" value="#{mBlog.blog.id}"/>
${id} //printing 4
<c:if test="${id > 0}">
<h:commandButton value="Update" action="#{mBlog.update}"/> //is not rendered
</c:if>
<c:if test="${id == 0}">
<h:commandButton value="Save" action="#{mBlog.save}"/> //is not rendered
</c:if>
Run Code Online (Sandbox Code Playgroud)
我不知道出了什么问题。在显示器中我只看到 4 个,没有别的。
拥有以下xhtml代码:
<h:form id="COTreeForm">
<p:tree value="#{COBean.root}" var="node" id="COTree" dynamic="true" selectionMode="single">
<p:ajax event="select" update="@(.coDetailsPanel)" listener="#{COBean.onNodeSelect}" />
<p:treeNode id="COtreeNode" type="customerOrder" icon="ui-icon-co">
<p:outputPanel id="CO_#{node.key}"> CO: #{node.key} </p:outputPanel>
<!-- <p:draggable for="CO_#{node.key}" helper="clone" /> -->
</p:treeNode>
<p:treeNode id="COItreeNode" type="customerOrderItem">
<p:outputPanel id="COI_#{node.key}" styleClass="ui-tree-node-label-coi"> COI: #{node.key} </p:outputPanel>
<!-- <p:draggable for="COI_#{node.key}" helper="clone" /> -->
</p:treeNode>
</p:tree>
</h:form>
Run Code Online (Sandbox Code Playgroud)
将<p:outputPanel id="CO_#{node.key}"> CO: #{node.key} </p:outputPanel>进行评估,以下面的HTML代码:
<span id="COTreeForm:COTree:0:CO_"> CO: customer1_co1 </span>
Run Code Online (Sandbox Code Playgroud)
为什么#{node.key}对id属性求值为空字符串?!请注意,它已被正确评估为标记内容.
假设我使用的rendered基本上是一个案例陈述.我有一个输入字段的标签和消息,但我希望字段本身根据具体情况而改变.因此:
<p:inputText id="foo" value="#{myBean.params[paramKey]}"
rendered="#{paramIsInput}" />
<p:calendar id="foo" value="#{myBean.params[paramKey]}"
rendered="#{paramIsCalendar}" />
Run Code Online (Sandbox Code Playgroud)
如果我这样做,那么我得到以下错误: java.lang.IllegalStateException: Component ID j_idt64:foo has already been found in the view.
作为一种解决方法,我为每个参数类型创建了许多标签/消息并更改了它们的ID.但这带来了我的问题.如果实际只渲染了一个带有id的组件,为什么我在jsf文件中定义了多个?有没有办法让他们拥有所有相同的ID?
我在JSF + JPA应用程序中有双边一对多关系.我想列出视图中列表中仅过滤的项目.在控制器中执行它很困难,是否可以像下面那样进行过滤?
<p:selectOneListbox id="cmbField" value="#{investigationItemController.current}" >
<f:selectItems value="#{investigationItemController.currentInvestigation.reportItems}" var="ri" itemLabel="#{ri.name}" itemValue="#{ri}" itemRendered="#{ri.retired ne true and ri.ixItemType eq 'Value'}" />
</p:selectOneListbox>
Run Code Online (Sandbox Code Playgroud)
由于itemRendered不是属性,我尝试了这个,但失败了.
<p:selectOneListbox id="cmbField" value="#{investigationItemController.current}" >
<ui:repeat value="#{investigationItemController.currentInvestigation.reportItems}" var="ri" >
<h:panelGroup rendered="#{ri.retired ne true and ri.ixItemType eq 'Value'}" >
<f:selectItem itemLabel="#{ri.name}" itemValue="#{ri}" />
</h:panelGroup>
</ui:repeat>
</p:selectOneListbox>
Run Code Online (Sandbox Code Playgroud)
所有者实体如下.
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class InvestigationItem extends ReportItem implements Serializable {
private static final long serialVersionUID = 1L;
@OneToMany(mappedBy = "investigationItem", cascade= CascadeType.ALL)
List<InvestigationItemValue> investigationItemValues;
public List<InvestigationItemValue> getInvestigationItemValues() {
return investigationItemValues;
} …Run Code Online (Sandbox Code Playgroud) 我强行使用一个非常旧版本的MyFaces 2.0.5我认为,动态包含EL导致这么多问题,所以我切换到静态包含ui:fragment
<ui:fragment rendered="#{filtersPopup.filterFileName == 'checkBoxFilters'}">
checkBoxFilters
<ui:include src="/analytics/checkBoxFilters.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
<ui:fragment rendered="#{filtersPopup.filterFileName == 'DateRelativeFilter'}">
DateRelativeFilter
<ui:include src="/analytics/DateRelativeFilter.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
<ui:fragment rendered="#{filtersPopup.filterFileName == 'listboxFilter'}">
listboxFilter
<ui:include src="/analytics/listboxFilter.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
Run Code Online (Sandbox Code Playgroud)
有了它,它仍然抱怨重复的id,因为我在这些源文件的夫妇上使用相同的id.所以它似乎rendered应该是false,它仍然使它成为组件树.但重复的ID很好.我可以轻松解决这个问题,所以现在当我提交表单时,我得到了这个例外
/analytics/checkBoxFilters.xhtml at line 24 and column 118 value="#{filtersPopup.filter.groups}": Property 'groups' not found on type ListBoxFilter
Run Code Online (Sandbox Code Playgroud)
所以从异常中可以看出,它ListBoxFilter是我想要的对象,所以只包含ListBoxFilter.xhtml,但正在访问checkBoxFilters.xhtml因此错误.知道如何解决这个问题吗?
您好,在我的项目中,我需要可视化货币价值,就我的 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 中的标准提供,并且搜索包含的库的文档不会显示任何明显的信息。
我正在尝试根据 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 也包含这些选择。迭代显然适用于上述情况,所以我不知道为什么它不显示菜单中的选项。我究竟做错了什么?
jsf ×10
primefaces ×4
facelets ×2
duplicates ×1
dynamic ×1
identifier ×1
java ×1
jpa ×1
jsf-2 ×1
jstl ×1
myfaces ×1
tabs ×1
uiinclude ×1
uirepeat ×1
wizard ×1