相关疑难解决方法(0)

ui:重复JSF 2.0无法呈现迭代p:行primefaces

我在这里遇到了一个问题,我的系统配置是Mojarra 2.1.7,Primefaces 3.2和使用Glassfish 3.1+.

在此之前,我使用以下代码很好地渲染了我的代码:

<p:tabView>
    <p:tab title="Offices Access" >
         <h:outputText value="Access | Offices Name | Offices Code | Parent Offices" style="font-weight: bold;"/>

         <ui:repeat value="#{userBean.officeses}" var="office">
              <h:panelGrid columns="2">
                   <p:selectBooleanCheckbox id="access#{office.officesID}" style="width: 50px;"/>
                   <h:outputLabel for="access#{office.officesID}" value="#{office.officesName} | #{office.officesCode} | #{office.parentOffices}"/>
               </h:panelGrid>
         </ui:repeat>
     </p:tab>
</p:tabView>  
Run Code Online (Sandbox Code Playgroud)

我发现这会产生相当丑陋的界面,所以我p:panelGrid从主要界面跑了过来.
在我编写一些代码并且从我的期望中它会起作用,但它不会:(
这段代码完美呈现标题,但在ui:repeat代码之后,它不会渲染它p:rowp:column内部.

这是代码:

<p:tabView>
    <p:tab title="Offices Access" >
        <p:panelGrid styleClass="centerContent">
             <f:facet name="header">
                 <p:row>
                     <p:column style="font-weight: bold;">Access</p:column>
                     <p:column style="font-weight: bold;">Offices Name</p:column>
                     <p:column style="font-weight: bold;">Offices Code</p:column>
                     <p:column style="font-weight: bold;">Above Level …
Run Code Online (Sandbox Code Playgroud)

primefaces jsf-2

3
推荐指数
1
解决办法
1万
查看次数

迭代JSF 1.2中的列表

有没有办法在不使用任何第三方组件的情况下迭代JSF 1.2中的列表?我知道我可以用战斧来做.我也知道可以使用JSTL完成,但我保留这是我的最后手段.我也无法使用,<ui:repeat>因为我们使用的是JSF 1.2.有什么优雅的方式喜欢<ui:repeat>在jsf 1.2中做到这一点吗?

jsf jsf-1.2

3
推荐指数
1
解决办法
3580
查看次数

JSTL c:forEach不会遍历集合

有谁有任何想法,为什么这个代码可以工作:

<h:outputText value="#{allocations[0].policyNumber}" />
Run Code Online (Sandbox Code Playgroud)

这段代码可以工作:

<c:forEach var="i" begin="1" end="5">
    <h:outputText value="aaa"/>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

但是这段代码不起作用(GUI中没有任何内容):

<c:forEach var="allocation" items="#{allocations}" >
    <h:outputText value="aaa"/>
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

我正在使用命名空间"http://java.sun.com/jstl/core".allocations是java中的一个集合.我已经尝试了我能想到的一切,并且不知道下一步该尝试什么.

jsf jstl

3
推荐指数
1
解决办法
5456
查看次数

如何使用primefaces的ajax刷新jstl测试?

例如:当我点击按钮时A。我得到了下面的文字:you have choosed A

但是当我更改按钮时,我得到了相同的文本,尽管#{bean.str}更改的值

这是我的代码:

<p:selectOneButton id="selectId" value="#{bean.str}">
            <f:selectItem itemLabel="A" itemValue="1" />
            <f:selectItem itemLabel="B" itemValue="2" />
            <f:selectItem itemLabel="C" itemValue="3" />
            <f:ajax event="change" render="tabView" listener="#{bean.change}" />
</p:selectOneButton>

<c:if var="test" test="#{bean.str =='1'}">
        <h:outputText value="you have choosed A" />
</c:if>
<c:if test="#{beanApplication.perspective=='2'}">
        <h:outputText value="you have choosed B" />
</c:if>
<c:if test="#{beanApplication.perspective=='3'}">
        <h:outputText value="you have choosed C" />
</c:if>
Run Code Online (Sandbox Code Playgroud)

我正在寻找一种<c:if>在单击按钮时刷新 JSTL测试的方法。

java ajax jsf jstl primefaces

3
推荐指数
1
解决办法
3857
查看次数

如何使用ui:在数据表中重复以追加列?

我想生成一个表列表.每月1张桌子.每月每天有1列.这是我正在使用的JSF部分.

<ui:repeat value="#{worklogService.months}" var="monthnum">
    <p:dataTable value="#{worklogService.getTableForMonth(monthnum)}" var="tabrow">
        <p:column headerText="Name">
            <h:outputLabel value="#{tabrow.get(0)}"></h:outputLabel>
        </p:column>
        <ui:repeat value="#{worklogService.getDaysOfMonth(monthnum)}" var="daynum">
            <p:column headerText="#{daynum}">
                <h:outputText value="#{tabrow.get(daynum)}"></h:outputText>
            </p:column> 
        </ui:repeat>
    </p:dataTable>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)

#{worklogService.months}回报List<Integer>.每月一个号码. #{worklogService.getTableForMonth(monthnum)}回报List<List<String>>.

每个表的第一列是相同的.我想根据月份生成所有其他列.结果是12个表只有1列(第一个).这可能是什么问题?以及如何解决?

jsf

3
推荐指数
1
解决办法
1万
查看次数

为什么<c:forEach>或<ui:repeat>不能访问<p:dataTable var>?

我正在使用jsf Mojarra 2.2.7,Java 8,Primefaces 5.1和netbeans 8.0.2

我有Event一个属性的班级List<GameRecord> gameRecordList.GameRecord包括List<Boolean> gamesEntered和其他属性.我的想法是,我有一个活动中的人员列表,如果他们进入投注或比赛,我正在配置.

在我的.xhtml文件中

<p:dataTable value="#{events.gameRecordList}" var="item" rowIndexVar="rowIndex">

                <p:column>#{item.field1}</p:column>
                <p:column>#{item.field2}</p:column>

                <c:forEach items="#{events.gameRecordList.get(rowIndex).gamesEntered}" var="game">
                    <p:column>
                        <p:selectBooleanCheckbox value="#{game}"/>
                    </p:column>
                </c:forEach>


            </p:dataTable>
Run Code Online (Sandbox Code Playgroud)

<c:forEach>应一起工作value="#{item.gamesEntered}",而不是整个字符串,但事实并非如此.我试过<ui:repeat>但无论哪种方式,页面都会出现空白,此数据应该出现.

这是否有意义或是否有理由需要完全寻址才能使其正常工作?

datatable foreach jsf jstl primefaces

3
推荐指数
1
解决办法
5964
查看次数

为selectManyCheckbox定义列

我需要selectManyCheckbox在4列中显示列表,但问题是该组件生成一个表,所以我不知道如何定义列.

我正在使用PF 3.4,我无法升级到PF 4.x. 你们有这个解决方案吗?

EDITED

现在我在我的代码中有这个

<h:form id="formAdminAccesosXPerfil">

    <h:panelGrid title="Accesos" columns="5">

    <c:forEach items="#{accesosXPerfilMB.listadoAcceso}" var="availableItem" varStatus="loop">

             <h:panelGroup>
                <p:selectBooleanCheckbox id="box_#{loop.index}" value="#{accesosXPerfilMB.checkBoxItems[availableItem]}" />
                <h:outputLabel for="box_#{loop.index}" value="#{availableItem.nombre}" />
            </h:panelGroup>
    </c:forEach>    

    </h:panelGrid>
Run Code Online (Sandbox Code Playgroud)

Managebean是@ViewScoped

我改变了建议的方法,因为它对我不起作用......

从:

public void save() {
List<E> selectedItems = checkboxItems.entrySet().stream()
    .filter(e -> e.getValue() == Boolean.TRUE)
    .map(e -> e.getKey())
    .collect(Collectors.toList());
// ...
Run Code Online (Sandbox Code Playgroud)

}

对此:

public void guardarAccesos(){
    try {
        System.out.println("Size: "+getCheckBoxItems().entrySet().size());

        for(BpAcceso acceso:getCheckBoxItems().keySet()){
            System.out.println("Acceso Seleccionado: "+acceso.getNombre());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我没有在hashMap上获得任何选定的项目.只是为了确保我使用的是jdk1.6

jsf multiple-columns primefaces selectmanycheckbox

3
推荐指数
1
解决办法
505
查看次数

JSF临时变量

有没有办法暂时保存JSF页面中的计算值?我想在不计算两次的情况下执行以下操作:

<h:outputText value="#{complexModel.currencyAmount.currency}">
<h:outputText value="#{complexModel.currencyAmount.amount}">
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用别名bean但是我收到一个错误,说java.lang.IllegalArgumentException - 行不可用.

例如

<t:aliasBean id="bean" alias="#{bean}" value="#{complexModel.currencyAmount}">
  <h:outputText value="#{bean.currency}">
  <h:outputText value="#{bean.amount}">
</t:aliasBean>
Run Code Online (Sandbox Code Playgroud)

谢谢.

jsf

2
推荐指数
1
解决办法
1万
查看次数

p:tooltip的动态"for"属性无法按预期工作

我试图在ui:repeat循环中将tooptips附加到commandButtons.我动态地创建了commandButtons的id,也为工具提示的"for"属性创建了id.这会出现以下错误:

    HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot find component "a_test" in view.
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
root cause

javax.faces.FacesException: Cannot find component "a_test" in view.
    org.primefaces.component.tooltip.TooltipRenderer.getTarget(TooltipRenderer.java:93)
    org.primefaces.component.tooltip.TooltipRenderer.encodeScript(TooltipRenderer.java:66)
    org.primefaces.component.tooltip.TooltipRenderer.encodeEnd(TooltipRenderer.java:35)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
    com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
    com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:504)
    com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:958)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
    org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.

Apache …
Run Code Online (Sandbox Code Playgroud)

jsf tooltip primefaces

2
推荐指数
1
解决办法
4758
查看次数

在模型视图更新之前,转换器是否始终运行?

例:

<h:form>
    <h:selectOneMenu value="#{bean.timezone}>
        <f:selectItems value="#{bean.availableTimezones} ... >
        <f:ajax render="currenttime" />
    </h:selectOneMenu>
</h:form>

<h:form id="currenttime">
    <h:outputText value="#{bean.currentTime}" >
        <f:convertDateTime dateStyle="short" type="both" timeZone="#{bean.timezone}" />
    </h:outputText>
</h:form>

<!-- bean.currentTime is of type 'Date' -->
Run Code Online (Sandbox Code Playgroud)

在该示例中,更改时区应该使文本currenttime显示在适当的时区.但事实并非如此.

我想这是因为转换器是在"应用请求"阶段计算的,所选时区的值是在"更新模型"阶段更新的.

我对吗?我不应该使用转换器吗?

谢谢!

jsf-2

2
推荐指数
1
解决办法
219
查看次数