2017-07-07 1 views
0

JSFアプリケーションでPrimeFaces 5.1を使用しています。このアプリケーションのリスティングページでは、私用ページテーブルを使ってPrimefaces Datatableを使用しています。表の列の1つの値は、SessionScopeを持つJSF ManagedBeanクラスで定義されたアクション・メソッドをコールするためにclickで定義されたprimefacesコマンド・リンクです。このデータテーブル自体は、h:formが定義されたテンプレートXHTMLを使用するXHTMLページで定義されています。したがって、このデータテーブルはそのh:フォームにネストされます。p:commandLinkがpで動作していませんページ1の後にページ番号付きデータテーブル

私が直面している問題は、ManagedBeanで定義されたメソッドが、データページの最初のページに表示されたcommandLinkから呼び出されているのに対し、後続のページのactionメソッドは呼び出されません。私も気付いたことは、合計レコードが100未満なので、XHTMLのデータテーブルの 'rows'属性の値を1ページあたり100行に設定すると、1ページだけがレンダリングされ、次に10または50を選択するとリストページのページ番号ドロップダウンリストから複数のページが表示されますが、リンクは正常に動作します。しかし、コードから、XHTMLコードで行の値をページあたり50行または10行に設定すると、問題が発生するようです。

私は放火犯JSと同様にクロームJSコンソールをチェックし、そこには誤りがあることも、Tomcatのログファイルは、私がDevelopmentからweb.xmljavax.faces.PROJECT_STAGEコンテキストのparamを設定しているにもかかわらず、すべてのログ・エラーを示していません。この動作の理由は何か、どうすれば解決できるのでしょうか?以下は

は、データテーブルのための私のJSFの抜粋である:以下

<p:dataTable id="data" widgetVar="dataTable" var="customer" value="#{customerServicePortaltBacking.customers}" 
     paginator="true" 
     rows="50" 
     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
     rowsPerPageTemplate="10,50,100"> 
<p:column style="width: 14%"> 
    <f:facet name="header"> 
     <p:outputLabel value="#{msg['customerId']}" styleClass="covFont"/> 
    </f:facet> 
    <h:outputText value="#{customer.customerId}" styleClass="covFont"/> 
</p:column> 
<p:column style="width: 66%"> 
    <f:facet name="header"> 
     <p:outputLabel value="#{msg['name']}" styleClass="covFont"/> 
    </f:facet> 
    <h:outputText value="#{customer.name}" styleClass="covFont"/> 
</p:column> 
<p:column style="width: 10%"> 
    <f:facet name="header"> 
     <p:outputLabel value="#{msg['deptId']}" styleClass="covFont"/> 
    </f:facet> 
    <h:outputText value="#{customer.deptId}" styleClass="covFont"/> 
</p:column> 
<p:column style="width: 10%"> 
    <f:facet name="header"> 
     <p:outputLabel value="#{msg['view']}" styleClass="covFont"/> 
    </f:facet> 
    <p:commandLink id="invoiceButton" value="#{msg['customers.invoices']}" action="#{customerServicePortaltBacking.goInvoiceCategories(customer)}" 
    ></p:commandLink> 
</p:column> 

</p:dataTable> 

は、管理対象Beanクラスからのコードです:

package com.assetworks.csportal; 

import com.assetworks.csportal.orm.*; 
import org.apache.commons.lang.StringUtils; 
import org.primefaces.component.datatable.DataTable; 
import org.primefaces.event.SelectEvent; 
import org.primefaces.event.UnselectEvent; 

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.SessionScoped; 
import javax.faces.context.FacesContext; 
import javax.servlet.ServletOutputStream; 
import javax.servlet.http.HttpServletResponse; 
import java.io.FileInputStream; 
import java.text.MessageFormat; 
import java.util.*; 
import java.util.logging.Logger; 

@ManagedBean 
@SessionScoped 
public class CustomerServicePortaltBacking { 

private static final Logger LOGGER = 
Logger.getLogger(CustomerServicePortaltBacking.class.getName()); 

private List<Customer> customers = null; 
private Stack<Screens> screensStack = new Stack<>(); 
//Screen 
private Screens screen = Screens.CustomerBrowse; 

private String customerName; 

private Customer customer; 

public String getCustomerName() { 
    if(customerName == null){ 

     String name = new DataAccess().getCustomerName(getContactId()); 
     if(name == null) 
      name = ""; 
     customerName = name; 
    } 
    return customerName; 
} 

public void setCustomerName(String customerName) { 
    this.customerName = customerName; 
} 

public List<Customer> getCustomers() { 
    if(customers == null){ 
     customers = new DataAccess().getCustomers(getContactId()); 
    } 
    List<Customer> filteredCustomers = new LinkedList<>(); 
    if(hasValue(this.getSearch())) { 
     String search = getSearch().toUpperCase(); 
     for (Customer customer : customers) { 
      if(customer.getCustomerId().indexOf(search) != -1 ||  customer.getName().toUpperCase().indexOf(search) != -1 || customer.getDeptId().indexOf(search) != -1){ 
       filteredCustomers.add(customer); 
      } 
     } 
    } 
    else{ 
     filteredCustomers = customers; 
    } 
    return filteredCustomers; 
} 

public String goCusomerList(){ 
    screensStack.clear(); 
    DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:data"); 
    if(dataTable != null) { 
     dataTable.resetValue(); 
     dataTable.processUpdates(FacesContext.getCurrentInstance()); 
    } 
    setScreen(Screens.CustomerBrowse); 
    return Screens.CustomerBrowse.getId(); 
} 

public String goHome(){ 
    search = null; 
    return goCusomerList(); 
} 

public String goInvoiceCategories(Customer customer){ 
    categories = null; 
    this.customer = customer; 
    this.setScreen(Screens.CustomerServiceCategory); 
    return Screens.CustomerServiceCategory.getId(); 
} 

public String goBack() { 
    this.screen = screensStack.pop(); 
    return getScreen().getId(); 
} 

public boolean hasValue(String str){ 
    return str != null && str.length() > 0; 
} 

public void setCustomer(Customer customer) { 
    this.customer = customer; 
} 

public String authenticateUser() { 
    isUserAuthenticated = true; 
    return goCusomerList(); 
} 

public void setScreen(Screens screen) { 
    screensStack.push(getScreen()); 
    this.screen = screen; 
} 

public Screens getScreen() { 
    return this.screen; 
} 

public String getMessage(String key, Object[] args){ 
    String result = "[Key " + key + " not found in messages.properties]"; 
    try { 
     FacesContext context = FacesContext.getCurrentInstance(); 
     ResourceBundle bundle = 
      ResourceBundle.getBundle("messages", 
      context.getViewRoot().getLocale()); 
     result = new MessageFormat(bundle.getString(key)).format(args); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    return result; 
} 


public String getVersion(){ 
    return Application.VERSION; 
} 

public String getScreenlabel() { 
    return getMessage(screen.getId(), new Object[0]); 
} 

public Customer getCustomer() { 
    return customer; 
} 

public void setCustomers(List<Customer> customers) { 
    this.customers = customers; 
} 

public boolean isCustomerExternal(){ 
    return customer.getDeptId().toUpperCase().startsWith("UFL"); 
} 
} 
+0

2 sugestions ... [mcve]を作成し、最新のPFバージョンと最新のjsfバージョンを試してください – Kukeltje

+0

逆の順序で実行される可能性があります – Kukeltje

答えて

0

必要に応じて、私は最終的に改ページしてDataTableの作業を得ました。 Primefacesのデータテーブルには、リンクを機能させるために働いたrowsfirstという2つの属性があります。私は、バッキングBeanクラスCustomerServicePortaltBackingに以下のようにgetterとsetterの2つの新しいプロパティrowsfirstを定義しました。

private Integer rows = 50; 

    private Integer first = 0; 

    public Integer getRows() { 
     return rows; 
    } 

    public void setRows(Integer rows) { 
     this.rows = rows; 
    } 

    public Integer getFirst() { 
     return first; 
    } 

    public void setFirst(Integer first) { 
     this.first = first; 
    } 

次に、私は、XHTMLで定義されたデータテーブルにfirst属性を追加し、firstプロパティに指摘し、以下のようにバッキングBeanで定義されたrowプロパティを指すようにデータテーブルにrow属性を更新

<p:dataTable id="data" widgetVar="dataTable" var="customer" value="#{customerServicePortaltBacking.customers}" 
       paginator="true" 
       first="#{customerServicePortaltBacking.first}" 
       rows="#{customerServicePortaltBacking.rows}" 
       paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
       rowsPerPageTemplate="10,50,100,200,500" > 

これは、ページ設定を使用して、データテーブルを正常に動作させました。

関連する問題