Rectangle 27 3

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
4. JSF 2.0 Serlvet Configuration

JSF PrimeFaces simple example: blank page only - Stack Overflow

jsf primefaces
Rectangle 27 0

I had the same error and solved it by setting a numerical id for every MenuItem. e.g. item.setId("1");

jsf 2 - Using Primefaces 5, should I be able to *dynamically* build a ...

jsf-2 primefaces
Rectangle 27 0

Sometimes when you build a JSP or XHTML page, and you enter in the navigator it doesn't work like a JSF page.

To fix it you need to view the web.xml and change the url-pattern like said Daniel before.

For example, if you have a page called:

and you have this in your web.xml

JSF PrimeFaces simple example: blank page only - Stack Overflow

jsf primefaces
Rectangle 27 0

Please follow these steps to get your code perfectly fine. in the XHTML file.

<p:fileUpload id="choose" validator="#{controllerClass.validateFile}" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"  value="#{controllerclass.uploadedfile}" required="true" mode="simple"/>

<p:commandButton ajax="false" id="saveBtn" update="errBrand,pnl" value="Save Brand" action="#{controllerClass.uploadFile()}" />

in the web.xml define following filter and servlet.

<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 the controller class you need to define method body like this

import org.primefaces.model.UploadedFile;
private UploadedFile uploadedfile;

if you want to define validation method for uploaded file you can write it like this

public void validateFile(FacesContext ctx,
            UIComponent comp,
            Object value) {
        List<FacesMessage> msgs = new ArrayList<FacesMessage>();
        UploadedFile file = (UploadedFile)value;
        int fileByte = file.getContents().length;
        if(fileByte > 15360){
            msgs.add(new FacesMessage("Too big must be at most 15KB"));
        }
        if (!(file.getContentType().startsWith("image"))) {
            msgs.add(new FacesMessage("not an Image file"));
        }
        if (!msgs.isEmpty()) {
            throw new ValidatorException(msgs);
        }
    }

Thanks for answering, but I am not sure I would be able to test that out as I am no more working on that area now. Anyway, I appreciate your help.

jsf - PrimeFaces p:fileUpload Listener method is never invoked for mod...

jsf jsf-2 primefaces
Rectangle 27 0

and some other attributes are not working In Primefaces.

If you want to use them then change mode from simple to advance or remove attribute of mode because by default mode is advance.

jsf 2 - primefaces fileupload dialog with file filter extension mode="...

file-upload jsf-2 primefaces
Rectangle 27 0

the solution is to put the content of the p:dialog between <h:form></h:form> and add to dialog appendToBody="false"

It is one or the other. Both is not needed

jsf - simple primefaces dialog does not affect value to property - Sta...

jsf primefaces datagrid
Rectangle 27 0

Sometimes when you build a JSP or XHTML page, and you enter in the navigator it doesn't work like a JSF page.

To fix it you need to view the web.xml and change the url-pattern like said Daniel before.

For example, if you have a page called:

and you have this in your web.xml

JSF PrimeFaces simple example: blank page only - Stack Overflow

jsf primefaces
Rectangle 27 0

You need to remove, glassfish-web.xml, glassfish-resources.xml and the next lines from web.xml:

<resource-ref>
    <res-ref-name>jdbc/shiro-primefaces</res-ref-name>
    <res-type>javax.sql.ConnectionPoolDataSource</res-type>
    <res-auth>Container</res-auth>
    <lookup-name>java:app/jdbc/shiro-primefaces</lookup-name>
</resource-ref>

You need to add the next lines to shiro.ini file with your datasource:

datasource.resourceName = java:jboss/datasources/mysql

java - simple login with shiro wildfly jsf and primefaces - Stack Over...

java jsf jboss wildfly shiro
Rectangle 27 0

You are missing the height and width :

<p:gmap center="41.381542, 2.122893" zoom="15" type="HYBRID" style="width:600px;height:400px" />
Four options are required to place a gmap on a page, these are center, zoom, type and style

Yeah, but when you look at the showcase it nowhere states the JavaScript that needs to be put into h:head. Until I found out I had already removed the style attribute, too. Bad luck.

jsf - PrimeFaces Gmap not rendering (in the simplest example) - Stack ...

jsf jsf-2 primefaces
Rectangle 27 0

Please follow these steps to get your code perfectly fine. in the XHTML file.

<p:fileUpload id="choose" validator="#{controllerClass.validateFile}" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"  value="#{controllerclass.uploadedfile}" required="true" mode="simple"/>

<p:commandButton ajax="false" id="saveBtn" update="errBrand,pnl" value="Save Brand" action="#{controllerClass.uploadFile()}" />

in the web.xml define following filter and servlet.

<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 the controller class you need to define method body like this

import org.primefaces.model.UploadedFile;
private UploadedFile uploadedfile;

if you want to define validation method for uploaded file you can write it like this

public void validateFile(FacesContext ctx,
            UIComponent comp,
            Object value) {
        List<FacesMessage> msgs = new ArrayList<FacesMessage>();
        UploadedFile file = (UploadedFile)value;
        int fileByte = file.getContents().length;
        if(fileByte > 15360){
            msgs.add(new FacesMessage("Too big must be at most 15KB"));
        }
        if (!(file.getContentType().startsWith("image"))) {
            msgs.add(new FacesMessage("not an Image file"));
        }
        if (!msgs.isEmpty()) {
            throw new ValidatorException(msgs);
        }
    }

Thanks for answering, but I am not sure I would be able to test that out as I am no more working on that area now. Anyway, I appreciate your help.

jsf - PrimeFaces p:fileUpload Listener method is never invoked for mod...

jsf jsf-2 primefaces
Rectangle 27 0

  • auto: This is the default mode and PrimeFaces tries to detect the best method by checking the runtime environment, if JSF runtime is at least 2.2 native uploader is selected, otherwise commons.
  • native: Native mode uses servlet 3.x Part API to upload the files and if JSF runtime is less than 2.2 and exception is being thrown.
  • commons: This option chooses commons fileupload regardless of the environment, advantage of this option is that it works even on a Servlet 2.5 environment.

You should choose only one option not paste all those three options. If you have commons-fileupload library in your project, I suggest you to choose commons.

in web.xml

<context-param>
   <param-name>primefaces.UPLOADER</param-name>
   <param-value>commons</param-value>
</context-param>
<h:form enctype="multipart/form-data">        
    <p:growl id="messages" showDetail="true" />

    <p:fileUpload value="#{fileUploadView.file}" mode="simple" />

    <br /> <br />

    <h:commandButton value="Dummy Action" 
                     action="#{fileUploadView.upload}">
    </h:commandButton>
</h:form>
@ManagedBean
@RequestScoped
public class FileUploadView {

    private UploadedFile file;

    public UploadedFile getFile() {
        return file;
    }

    public void setFile(UploadedFile file) {
        this.file = file;
    }

    public void upload() {
        System.out.println("Uploaded File Name Is :: " + 
                file.getFileName() + 
                " :: Uploaded File Size :: " + file.getSize());
        if(file != null) {
            FacesMessage message = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");
            FacesContext.getCurrentInstance().addMessage(null, message);
        }
    }

}

jsf - PrimeFaces simple fileUpload: NullPointerException - Stack Overf...

jsf file-upload primefaces nullpointerexception
Rectangle 27 0

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
4. JSF 2.0 Serlvet Configuration

JSF PrimeFaces simple example: blank page only - Stack Overflow

jsf primefaces