小编jav*_*aMS的帖子

在JSF中有一个"常量"类

我正在使用JSF/Primefaces构建一个Web应用程序.我需要一个"常量"类,即一个由常量组成的类.这些常量主要是将在整个应用程序中使用的导航命令.我这样做的原因是为了避免在ad-hoc基础上实例化字符串.

我如何实现这一点,使得可以从支持bean和XHTML文件访问常量?

我尝试过使用@ApplicationScoped和使用Singleton模式(Singleton类),但由于范围问题,我无法使用它.

或许我只是使用错误的方法.欢迎任何想法/建议.

java jsf constants el primefaces

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

使用return/enter键在Primefaces 3.4 in-cell editable datatable中保存已编辑的单元格

正如标题所说,切换到编辑模式后,我希望在按Enter/return键时具有相同的功能,而不是单击"保存"按钮.

我尝试使用p:hotkey执行此操作,但显然p:hotkey不适用于可聚焦的可编辑组件.

有没有其他方法可以做到这一点,而不是深入研究JQuery?

jquery jsf primefaces

7
推荐指数
1
解决办法
2872
查看次数

如何使Primefaces selectonemenu处于禁用状态?

我需要使用p:selectonemenu并禁用它,即它应该在帖子中提交但它应该是只读的.请注意,我不想使用disabled属性,因为这会阻止发布.

我已经在这个论坛上看到这可以通过使用隐藏字段来实现,但是我不明白这是如何实现的.如果有人能在这方面为我提供一些帮助,我将不胜感激.

<p:inputText id="cpr" value="#{customerbean.customer.cpr}">
    <p:ajax event="change" listener="#{customerbean.fetchCustomerDatafromCBS}" update="nationality address passportno name nationality dob address mailingaddress gender mobileno landlineno otherno email maritalstatus nochildren" immediate="true" >
         <f:param name="cprNumber" value="#{customerbean.customer.cpr}"/>
    </p:ajax>                 
    <f:validator validatorId="cprValidator" />                    
</p:inputText>   


<p:selectOneMenu id="gender" value="#{customerbean.customer.gender}" required="!#{customerbean.disabled}" requiredMessage="#{text['validation.error.required.gender']}" disabled="#{customerbean.disabled}">                      
    <f:selectItem itemLabel="Select One" itemValue="" noSelectionOption="true" />  
    <f:selectItem itemLabel="Male" itemValue="Male" />  
    <f:selectItem itemLabel="Female" itemValue="Female"  />  
</p:selectOneMenu>                

<p:inputText  type="hidden" value="#{customerbean.customer.gender}" />
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

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

Primefaces 3.4 dataexporter不导出值p:cellEditor

我正在使用Primefaces 3.4并尝试使用单元格内部编辑导出数据表.它似乎不起作用.

我做了以下事情:

修改了org.primefaces.component.export.Exporter第143行并添加了这个:

else if (component instanceof CellEditor) { // Handle in-cell editable datatables
    return exportValue(context, ((CellEditor) component).getFacet("output"));
}
Run Code Online (Sandbox Code Playgroud)

这会导致顶部的额外行以及带有数据的实际单元格右侧的额外列.使用Excel文件可以,因为它们不是"可见"但PDF看起来很糟糕.

  1. 有没有办法让PF 3.4支持这个而不改变源代码?
  2. 如果上述答案是否定的,我是否可以在没有附加行/列的情况下生成PDF?

java jsf primefaces

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

@Injection不适用于CDI bean

我有一个CDI bean,我正在使用@ConversationScoped.当我尝试为Conversation对象执行@Inject时,我得到一个NPE.

  @ConversationScoped
@Named("customerbean")
public class CustomerBean implements Serializable {

    @Inject
    private Conversation conversation;    

    private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("ba");
    private EntityManager em;
    private Customer customer;
    boolean disabled;    

    public CustomerBean() {
        beginConversation();
        customer = new Customer();
        em = emf.createEntityManager();
        disabled = false;
    }

    private void beginConversation() {
        if (this.conversation.isTransient()) {
            this.conversation.begin();
            return;
        }
        throw new IllegalStateException();
    }
Run Code Online (Sandbox Code Playgroud)

我在WEB-INF目录中有beans.xml文件(尽管是空的).例外情况如下:

INFO: Exception when handling error trying to reset the response.
com.google.common.collect.ComputationException: java.lang.RuntimeException: java
.lang.NullPointerException
        at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdap
ter.get(ComputingConcurrentHashMap.java:397)
        at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientPr
oxyProvider.java:102)
        at …
Run Code Online (Sandbox Code Playgroud)

java jsf cdi

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

Primefaces 3.5 + OmniFaces 1.3 SelectOneMenu的SelectItemsIndexConverter问题

我正在使用Primefaces 3.5 2012年12月5日SNAPSHOT,Mojarra 2.1.14和Tomcat 7.0.33.

对于POJO对象的单元格内编辑模式(非行内),使用在ah:selectOneMenu中表示的模型/实体类,使用'click'作为celleditevent值,每当您单击一个对象然后单击通过单击其他对象,前一个对象显示其值而不是其标签.这只是"装饰性",当您重新加载页面时,它将显示标签值.

<p:dataTable id="insurancepolicyTable" var="insurancepolicy" widgetVar="insurancepolicyList" value="#{insurancepolicybean.objectList}" paginator="true" rows="15" paginatorPosition="bottom" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" currentPageReportTemplate="#{text['table.insurancepolicy.filter.count']}" rowsPerPageTemplate="15,25,50,100" emptyMessage="#{text['table.insurancepolicy.filter.notfound']}" filteredValue="#{insurancepolicybean.filteredObject}" editable="true" editMode="cell" cellEditEvent="click" draggableColumns="true" rowKey="#{insurancepolicy.id}" > 


               <p:column id="branchColumn" headerText="#{text['label.branch']}" sortBy="#{insurancepolicy.branch.name}" filterBy="#{insurancepolicy.branch.name}" filterMatchMode="contains">  
                <p:cellEditor>  
                    <f:facet name="output">  
                        <h:outputText value="#{insurancepolicy.branch.name}" />  
                    </f:facet> 
                    <f:facet name="input">  
                        <div  class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all">
                            <p:selectOneMenu id="branchselectinsurancepolicylist" value="#{insurancepolicy.branch}" styleClass="customSelect" converter="omnifaces.SelectItemsIndexConverter">                      
                                <f:selectItems value="#{insurancepolicybean.branchList}" var="branch" itemLabel="#{branch.name}" itemValue="#{branch}" />                    
                            </p:selectOneMenu>    
                        </div>
                    </f:facet> 
                </p:cellEditor>    
            </p:column>   
            <p:ajax event="cellEdit" listener="#{insurancepolicybean.onEdit}" update="@form" />
            <pe:resetInput event="cellEdit" for="@form" />

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

java jsf primefaces omnifaces

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

标签 统计

jsf ×6

primefaces ×5

java ×4

cdi ×1

constants ×1

el ×1

jquery ×1

omnifaces ×1