1

I am developing small web app using JSF/PrimeFaces. I am able to call bean from web, however, I am unable to return web. This is what I have:

requestLeave.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>Request leave</title>
    </h:head>

    <h:body>
        <script language="javascript">
            var today = new Date();
            document.write(today);
        </script>

        <h:form id="form"  >
            <h:panelGrid id= "grid" columns="2" cellpadding="5">
                <f:facet name="header">
                    <p:messages id="msgs" />
                </f:facet>

                <h:outputLabel for="title" value="Leave Title:" style="font-weight:bold" />
                <p:inputText  value="#{requestLeave.titleLeave}" required="true" requiredMessage="title is required." />

                <h:outputLabel for="type" value="Type:" style="font-weight:bold" />
                <p:inputText  value="#{requestLeave.typeLeave}" required="true" requiredMessage="type is required." />

                <p:commandButton value="Submit" actionListener="#{requestLeave.buttonAction}"  />
            </h:panelGrid>
        </h:form>
    </h:body>
</html>

RequestLeave.java

import javax.faces.bean.ManagedBean;    

@ManagedBean    
public class RequestLeave {

    private String titleLeave;
    private String typeLeave;

    public String getTitleLeave() {
        return titleLeave;
    }

    public void setTitleLeave(String titleLeave) {
        this.titleLeave = titleLeave;
    }

    public String getTypeLeave() {
        return typeLeave;
    }

    public void setTypeLeave(String typeLeave) {
        this.typeLeave = typeLeave;
    }

    public String buttonAction() {

        System.out.println("leave title " + titleLeave);
        System.out.println("leave type " + typeLeave);

        return ("index.jsp");
    }
}

With this, I cannot return to index.jsp. Can anyone help me? Thanks in advance.

Tiny
  • 27,221
  • 105
  • 339
  • 599
sandesh
  • 59
  • 2
  • 7

1 Answers1

3

Change the actionListener attribute to action:

<p:commandButton value="Submit" action="#{requestLeave.buttonAction}" />

More info:

Community
  • 1
  • 1
Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147
  • thank you kocko, It solved my question. however, only basic html is rendered in new navigated page. Is there any way that I can rendered my primefaces components present in page? – sandesh Jan 11 '15 at 09:50
  • This is another question and you should start a new thread for it. A little research of your may also be reasonable, because there are plenty of threads that can be in use for you. – Konstantin Yovkov Jan 11 '15 at 09:53