相关疑难解决方法(0)

JSF中的范围2

我有一个CRUD应用程序..在数据的提取位置,显示n编辑n存储回db.页面之间还有顺序访问,第二页上需要输入第一页上输入的信息,依此类推.什么是最好的范围和原因?

何时使用哪个范围?每个范围的生命周期是什么.

另外,我找不到任何关于范围的好教程.如果您知道相同的情况,请指导.

谢谢,Shikha

jsf-2

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

ajax更新期间丢失的组件值

我使用的是PrimeFaces 3.3.1和JSF 2.0,使用的服务器是Oracle Weblogic 11gR1

以下是我的代码.

<p:panel id="personDetailsPanelId" header="#{msg.personDetails}">  

            <!-- Radio Button -->  
            <h:panelGrid columns="3" style="align:center">  
                <h:outputText value="#{msg.accountCategory}" />  
                <p:spacer width="10px" />  
                <p:selectOneRadio id="singleJointAccountRadioId"  
                    layout="horizontal"  
                    value="#{captureAccountDetailBackingBean.accountCategory}">  
                    <f:selectItems  
                        value="#{captureAccountDetailBackingBean.accountcategoryList}">  
                    </f:selectItems>  
                    <p:ajax process="@this" event="change" update="@form"  
                        partialSubmit="true" />  
                </p:selectOneRadio>  
            </h:panelGrid>  

            <p:spacer height="30px;" />  

            <h:panelGrid id="accountDetailsId" columns="3">  
                <h:panelGrid id="firstAccountHolderId" columns="2"  
                    styleClass="float-left ">  
                    <p:graphicImage  
                        value="/com/cas/pages/common/images/person_icon.jpg" />  
                    <h:outputText value="#{msg.firstAccountHolder}" />  

                    <!-- Person Name -->  
                    <h:panelGrid columns="2">  
                        <h:outputText value="#{msg.nameofPerson}" />  
                        <span style="color: red;">*</span>  
                    </h:panelGrid>  
                    <p:inputText  
                        value="#{captureAccountDetailBackingBean.accountHolder1.personName}"  
                        size="25" required="true" />  

                    <!-- Person Address -->  
                    <h:panelGrid columns="2">  
                        <h:outputText value="#{msg.address}" …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

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

jsf中的SelectBooleanCheckbox

嗨,我是JSF的新手,有这样的问题.在我的页面上,我有新闻列表,每个新闻都有复选框(我们可以选中此复选框,然后删除已检查的新闻).这很好用.但是在删除之后我返回到我的页面然后按F5然后我的应用程序认为检查了删除后的复选框并将其删除.例如我有这个: 在此输入图像描述

按删除按钮,并具有: 在此输入图像描述 按f5,我看到了这个: 在此输入图像描述

所以我的删除方法如下所示:

Map<Integer, Boolean> allCheckboxes = newsForm.getCheckboxes();
Set<Integer> checkboxes = newsForm.getCheckboxes().keySet();
Set<Integer> checkedCheckboxes = new HashSet<>();
for(Integer id : checkboxes){
    boolean value = allCheckboxes.get(id);
    if(value){
        checkedCheckboxes.add(id);
    }
}
if (checkedCheckboxes.size() != 0) {
    newsDao.deleteNewsById(checkedCheckboxes.toArray());
} else {
    Integer[] delete = { newsForm.getNews().getId() };
    newsDao.deleteNewsById(delete);
}
newsForm.setNewsList(newsDao.getNewsList());
return list() + REDIERCT;
Run Code Online (Sandbox Code Playgroud)

在我的页面我使用selectBooleanCheckbox:

<h:selectBooleanCheckbox id="checkbox" 
                            value="#{newsForm.checkboxes[news.id]}" />
Run Code Online (Sandbox Code Playgroud)

所以我不明白为什么当我按f5时我的Map<Integer, Boolean> allCheckboxes一些元素值为true.每次删除后我都会重新创建Map<Integer, Boolean> allCheckboxes

更新 news.xhtml

<h:form id="main-form" onsubmit="return getSelectedCheckBoxes()">
                <h:commandLink styleClass="news-link" action="#{controller.list}"
                    value="#{messages['body.news']}" />
                &gt;&gt;
                <h:outputText value="#{messages['body.news.titles.list']}" /> …
Run Code Online (Sandbox Code Playgroud)

java jsf

5
推荐指数
1
解决办法
3865
查看次数

在时间间隔后使特定的托管bean实例过期

我有2个JSF托管bean A,B我需要A在2分钟B后和5分钟后过期/销毁/销毁.我检查了这个相关的问题,从一个bean中定时,但是整个会话到期了.我不想让整个会话到期.

如何使用自定义范围实现此目的?

jsf scope managed-bean

5
推荐指数
1
解决办法
1145
查看次数

没有 @ViewScoped 的 JSF

我已经使用 JSF 很多年了,在下一个项目中,我们的目标是使 Web 层尽可能无状态。我正在探索的一种可能性是去除@ViewScoped豆子以支持@RequestScoped@SessionScoped根据需要加上一两个豆子)。这对于带有 AJAX、数据表和条件渲染的复杂页面来说很麻烦。我的问题是:JSF(和 PrimeFaces)与无状态 Web bean 的工作情况如何?这是我应该继续探索的东西,还是@ViewScope现在如此基本以至于不值得付出努力?

我很感激在我写这个问题时它可能会被关闭为“主要基于意见”,但我希望它不是,我对@ViewScope解决的具体问题感兴趣,以及我必须重新解决哪些历史性的解决方法-通过忽略引入@ViewScoped

jsf primefaces view-scope

5
推荐指数
1
解决办法
273
查看次数

JSF 2.0 - ViewScope和SessionScope的优势?

如果有人可以帮助我理解,当我们将SessionBean注入其中时ViewScoped bean的优势是什么呢会很棒.

我们还能节省会话内存的使用吗?

如果我们只使用SessionScoped bean或ViewScoped bean注入SessionBean,我相信会话内存占用没有区别.

当使用SessionScoped bean实现所有目标时,为什么我们要经历使用View和Session scoped bean的麻烦.

谢谢,Sundeep

jsf

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

有条件地呈现的输入组件不更新值

使用jsf 2和Primefaces 3.4

我知道有很多类似的问题,但没有一个在这个问题上有效.

当单击命令按钮后,panelGrid"inner"以固定值"true"(<h:panelGrid id="inner" rendered="true">)=> 呈现时,输入组件正确更新#{tableMatchesBean.mergedAuthorAjax}的值,

但是当此面板的呈现是有条件的时:<h:panelGrid rendered="#{spellCheckBean.renderInputMerge}"> =>然后输入组件是静默的(没有跟踪tableMatchesBean.mergedAuthorAjax已被调用).

注意:我使用嵌套的panelGrids将渲染条件放在需要有条件渲染的组件的父元素(输出和输入组件)中.任何帮助赞赏.

[评论后编辑:] xhtml页面的作用:
- 当用户点击selectOnebutton中的"merge"选项时,ajax更新会将"renderInputMerge"切换为true,从而导致显示"外部"组件.它工作正常.在此组件中,有一个输入字段,显示OK.
- 在用户单击commandLink按钮后,我需要检索此输入字段的值.如上所述,我有一个问题.

xhtml:

<h:body style ="width:100%">


    <h:form id = "currMatch">

        <h:panelGrid>

            <p:selectOneButton id ="selection" value="#{spellCheckBean.optionChosen}">
                <f:selectItem itemLabel="keep both" itemValue="1" />
                <f:selectItem itemLabel="delete both" itemValue="2" />
                <f:selectItem itemLabel="merge" itemValue="3" />
                <p:ajax update="outer" />
            </p:selectOneButton>

        </h:panelGrid>

         <h:panelGrid id="outer" >
            <h:panelGrid id="inner" rendered="#{spellCheckBean.renderInputMerge}">
            <!-- **the line above does not update**, this one does    <h:panelGrid rendered="true">-->

                <h:outputText …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces jsf-2

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

了解Java中用于容器管理的对象的垃圾收集

比方说,我有一个名为托管bean A@RequestScoped假设A有另一个管理bean的引用BB被宣布为@SessionScoped.A引用另一个具有更长范围的bean 的事实是否会阻止A在结束时收集垃圾HttpRequest

情况是否会改变另一种方式,即如果B包含对A?的引用?如果是,那么为什么?

java jsf garbage-collection

4
推荐指数
1
解决办法
1112
查看次数

如何在JSF中创建切换按钮?

如何在JSF中创建切换按钮?

基本上,我需要两个按钮“ in”和“ out”。它们本质上调用了相同的托管Bean,但是由于每次单击,都应禁用一个,而应启用另一个,反之亦然。如何才能做到这一点?我应该使用ajax功能吗?

jsf toggle jsf-2 commandbutton

4
推荐指数
1
解决办法
5377
查看次数

commandLink操作未执行

我有以下XHTML:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <head>
        <title>TODO supply a title</title>
    </head>
    <body>
        <f:metadata>
            <f:viewParam id="productCV" name="productName" value="#{productBean.product}"
                         converter="#{productConverter}" required="true"/>
        </f:metadata>

        <ui:composition template="/templates/mastertemplate.xhtml">
            <!-- Define the page title for this page-->
            <ui:define name="pageTitle">
                <h:outputFormat value="#{msgs.productPageTitle}">
                    <f:param value="#{productBean.product.description}"/>
                </h:outputFormat>
            </ui:define>

            <!-- Pass the categoryName parameter to the sidebar so the category of this product is highlighted-->
            <ui:param name="categoryName" value="#{productBean.product.categoryName}"/>

            <ui:define name="content">
                <!-- If productconversion failed, show this error-->
                <h:message id="error" for="productCV" style="color: #0081c2;" rendered="#{productBean.product == null}" />

                <!-- If productconversion succeeded …
Run Code Online (Sandbox Code Playgroud)

jsf jsf-2

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