JSF 2.0 cannot display dialog from simple

Recently, I have had a lot of problems with the components of price lists, so I know why. I am using glassfishV3.0, and my version in the form of a perforation is 2.2.1. My problem is that I can not do p: the surface rendering dialog when I click on the table row. I do almos exactly as it does in their example: http://www.primefaces.org/showcase/ui/datatableComplex.jsf

I think my problem has something to do with some configuration, because I am also having problems with other perffaces components. Can someone give me a hand, please, and tell me what I’m missing to be able to use components of primes like this without any problems? Here is the code:

JSF:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:p="http://primefaces.prime.com.tr/ui"> <ui:composition template="WEB-INF/templates/BasicTemplate.xhtml"> <ui:define name="resultsForm"> <h:form enctype="multipart/form-data"> <h:inputText id="search" value="" /><h:commandButton value="search"/> <p:dataTable var="garbage" value="#{resultsController.allGarbage}" dynamic="true" paginator="true" paginatorPosition="bottom" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15" selection="#{resultsController.garbage}" selectionMode="single" onRowSelectUpdate="display" onRowSelectComplete="fileDialog.show()"> <p:column sortBy="#{garbage.filename}" parser="string" filterBy="#{garbage.filename}" filterMatchMode="startsWith"> <f:facet name="header"> <h:outputText value="Filename" /> </f:facet> <h:outputText value="#{garbage.filename}" /> </p:column> <p:column filterBy="#{garbage.description}" filterMatchMode="contains"> <f:facet name="header"> <h:outputText value="Description" /> </f:facet> <h:outputText value="#{garbage.description}" /> </p:column> <p:column sortBy="#{garbage.uploadDate}" parser="string"> <f:facet name="header"> <h:outputText value="Upload date" /> </f:facet> <h:outputText value="#{garbage.uploadDate}" /> </p:column> </p:dataTable> <p:dialog header="Modal Dialog" widgetVar="fileDialog" modal="true" height="200"> <h:panelGrid id="display" columns="2" cellpadding="4"> <h:outputText value="FileName:" /> <h:outputText value="#{garbage.filename}" /> <h:outputText value="Upload date:" /> <h:outputText value="#{garbage.uploadDate}" /> <h:outputText value="Description" /> <h:outputText value="#{garbage.description}" /> </h:panelGrid> </p:dialog> </h:form> </ui:define> </ui:composition> </html> 

Driven bean

 @ManagedBean @ViewScoped public class ResultsController implements Serializable{ @EJB private ISearchEJB searchEJB; private Garbage garbage; public List<Garbage> getAllGarbage() { List<Garbage> tmpGarbage = new ArrayList<Garbage>(); for(Garbage g :searchEJB.findAllGarbage()) { tmpGarbage.add(g); } return tmpGarbage; } public Garbage getGarbage() { return garbage; } public void setGarbage(Garbage garbage) { this.garbage = garbage; } 

JSF before is the composite page that I use inside this template

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>title</title> <script type="text/javascript"> PrimeFaces.widget.Uploader.prototype._createPostParams = function() { var b = {}; b[PrimeFaces.PARTIAL_REQUEST_PARAM] = true; b[PrimeFaces.PARTIAL_PROCESS_PARAM] = this.id; b[PrimeFaces.PARTIAL_SOURCE_PARAM] = this.id; b[PrimeFaces.VIEW_STATE] = PrimeFaces.ajax.AjaxUtils.encodeViewState(); if (this.cfg.update) { b[PrimeFaces.PARTIAL_UPDATE_PARAM] = this.cfg.update } var a = PrimeFaces.getCookie("JSESSIONID"); if (this.cfg.script.indexOf("jsessionid") == -1) { paramIndex = this.cfg.script.indexOf('?'); if (paramIndex != -1) { this.cfg.script = this.cfg.script.substring(0, paramIndex) + ";jsessionid=" + a + this.cfg.script.substring(paramIndex); } else { this.cfg.script = this.cfg.script + ";jsessionid=" + a; } } b['cid'] = "#{javax.enterprise.context.conversation.id}"; return b; }; PrimeFaces.widget.Uploader.prototype.createPostParams = PrimeFaces.widget.Uploader.prototype._createPostParams; </script> <script type="text/javascript" src="/ primefaces_resource/2.1/yui/datasource/datasource-min.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/primefaces/paginator/paginator.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/yui/datatable/datatable-min.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/primefaces/datatable/datatable.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/yui/swf/swf-min.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/yui/charts/charts-min.js"></script> <script type="text/javascript" src="/primefaces_resource/2.1/primefaces/charts/charts.js"></script> </h:head> <body> <ui:insert name="resultsForm"/> </body> </html> 

Web.xml configuration

  <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/pages/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>pages/index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>Resource Servlet</servlet-name> <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Resource Servlet</servlet-name> <url-pattern>/primefaces_resource/*</url-pattern> </servlet-mapping> <filter> <filter-name>PrimeFaces FileUpload Filter</filter-name> <filter-class>org.primefaces.webapp.filter.FileUploadFilter </filter-class> </filter> <filter-mapping> <filter-name>PrimeFaces FileUpload Filter</filter-name> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> 

In table i, located above the endless jobs, just the sortBy function and the p: dialog don't work. These are the messages that appear on the eclipse console when I refresh the page:

SEVERE: line 1:61 there is no viable alternative in the character ';'

I don’t understand what this means, I think I have some kind of configuration problem, not a syntax error. I will be very happy if anyone can help me fix this, please.

+8
java java-ee jsf jsf-2 primefaces
source share
1 answer

uhmmm I am creating a simplified version of your code and my work is excellent. Each time I click on a line, a dialog appears. Try running this code in a new project and see if it works.

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" href="themes/blitzer/skin.css?${config.startupTime}" type="text/css"/> </h:head> <h:body> <h:form enctype="multipart/form-data"> <p:dataTable var="item" value="#{myBean.myList}" dynamic="true" paginator="true" paginatorPosition="bottom" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15" selection="#{myBean.selectedResult}" selectionMode="single" onRowSelectUpdate="display" onRowSelectComplete="fileDialog.show()"> <p:column> <h:outputText value="#{item}"/> </p:column> </p:dataTable> </h:form> <p:dialog widgetVar="fileDialog"> <h:outputText value="Dialog open"/> </p:dialog> </h:body> </html> 

and here is my bean

 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.test; import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; /** * * @author KingdomHeart */ @ManagedBean @ViewScoped public class MyBean { private List<String> myList; private String selectedResult; public MyBean() { } @PostConstruct public void init(){ myList = new ArrayList<String>(); myList.add("Test1"); myList.add("Test2"); myList.add("Test3"); myList.add("Test4"); myList.add("Test5"); } public List<String> getMyList() { return myList; } public void setMyList(List<String> myList) { this.myList = myList; } public String getSelectedResult() { return selectedResult; } public void setSelectedResult(String selectedResult) { this.selectedResult = selectedResult; } } 

Sfrj update enter image description here

As you can see, more than one of my lines is yellow, this does not mean that it is. selectionMode = "single" does not work correctly.

Update from Harry

Here's how to convert date type to string

 public String formatDate(Date date) { if (date != null) { SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy"); return sdf.format(date); } return null; } 

Then your JSF will be like this:

 h:outputText value="#{resultsController.formatDate(garbage.uploadDate)}" /> 

Update 2 with sfrj enter image description here

Here is the new JSF page:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:p="http://primefaces.prime.com.tr/ui"> <ui:composition template="WEB-INF/templates/BasicTemplate.xhtml"> <ui:define name="resultsForm2"> <h:form enctype="multipart/form-data"> <p:dataTable var="garbage" value="#{resultsController.allGarbage}" dynamic="true" paginator="true" paginatorPosition="bottom" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15" selection="#{resultsController.selectedGarbage}" selectionMode="single" rowSelectListener="#{resultsController.rowIsSelected}"> <p:column> <h:outputText value="#{garbage.filename}"/> </p:column> </p:dataTable> </h:form> <p:dialog widgetVar="fileDialog"> <h:outputText value="Dialog open"/> </p:dialog> </ui:define> </ui:composition> </html> 
+7
source share

All Articles