p:commandLink in p:dataTable只有第一页有效

时间:2013-12-05 13:22:56

标签: java jsf primefaces

我在这里做错了什么? 第一页没有问题。当我在第一页中点击带有“p:commandlink”的超链接时。这非常有效。当我点击下一页时,我的对话窗口中没有任何结果。 我已将SessionScoped更改为ViewScoped,但所有内容都相同,只有第一页的超链接才有效。

我使用: Primefaces 4.0

        <p:dataTable id="mycontent" 
                     value="#{outputBean.lazyModel}" 
                     var="item"
                     paginator="true" rows="10" 
                     paginatorTemplate="  {PageLinks} "  
                     rowsPerPageTemplate="5,10,15"
                     lazy="true">  


            <p:column>
               <p:commandLink  value="#{item.name} #{item.model}" 
                               process="@this" update=":workform:myDialog" 
                               oncomplete="dialogcontent.show();" >
                    <f:setPropertyActionListener value="#{item}" target="#{outputBean.data}" />  
                </p:commandLink>
            </p:column>

        </p:dataTable>  


        <p:dialog id="myDialog"  
                  widgetVar="dialogcontent"  resizable="false"   modal="true"
                  height="575" width="730">

                    <h:outputText value="Click: "/>

                    <h:outputText id="myeniid" value=" #{outputBean.data.id}"/>

        </p:dialog>

@ManagedBean
@SessionScoped
public class OutputBean implements Serializable{

@EJB
private OutputService service;
private LazyDataModel<Object> lazyModel;
private OutputQueryData data;    


public OutputBean() {
}



   public LazyDataModel<Object> getLazyModel() {

                lazyModel = new LazyDataModel<Object>() {
                    @Override
                    public List<Object> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {

                        int start = first;
                        int end = first + pageSize;
                        int countbuffer = 0;


                        List<Object[]> empList = null;
                        OutputQueryData qData = new OutputQueryData(start, end, sortField, filters);

                        List<Object> empati = new ArrayList<Object>();
                        empList = service.findMyData(qData);
                        countbuffer = service.myrowcount(qData);

                        if (empList != null && !empList.isEmpty()) {
                            OutputQueryData qDataZellen;
                            for (Object[] obj : empList) {
                                qDataZellen = new OutputQueryData(obj[0], obj[1], obj[2], obj[3]);
                                empati.add(new OutputQueryData(obj[0], obj[1], obj[2], obj[3]));
                            }
                        }
                        this.setRowCount(countbuffer);
                        FacesContext context = FacesContext.getCurrentInstance();
                        String viewId = context.getViewRoot().getViewId();
                        ViewHandler handler = context.getApplication().getViewHandler();
                        UIViewRoot root = handler.createView(context, viewId);
                        root.setViewId(viewId);
                        context.setViewRoot(root);

                        return empati;
                    }

                };

    return lazyModel;
}




public OutputQueryData getData() {
    return data;
}

public void setData(OutputQueryData data) {
    this.data = data;
}

}





public class OutputQueryData {

private Object id;
private Object name;
private Object model;
private List<Object[]> result;
private Map<String, String> filters;
private int start;
private int end;
private String sortField;
private Object pager;
private int totalResultCount;


public OutputQueryData(){
}

public OutputQueryData(int totalResultCount) {
    this.totalResultCount = totalResultCount;
}


public OutputQueryData(int start, int end, String sortField, Map<String, String> filters) {

    this.result = result;
    this.totalResultCount = totalResultCount;
    this.start = start;
    this.end = end;
    this.sortField = sortField;
    this.filters = filters;
}

public OutputQueryData(Object id, Object name, Object model) {
    this.id = id;
    this.name = name;
    this.model = model;

}

//All Getter and Setters
...................................................


}

0 个答案:

没有答案