0

Here is a Facelets file which is used to get first and last name and after that will go to the another Facelets file:

<?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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <h:head><title>User Form</title></h:head>

    <h:body>
    <h:form>
        <h:panelGrid columns="2">
            <p:graphicImage value="resources/images/image.jpg" width="50%"/>

            <p:panelGrid columns="2" width="50%">
                <f:facet name="header">
                    User Form
                </f:facet>
                <h:outputLabel for="firstname" value="Firstname: *"/>
                <p:inputText id="firstname" value="" label="Firstname"/>

                <h:outputLabel for="surname" value="Surname: *"/>
                <p:inputText id="surname" value="" required="true" label="Surname"/>

                <f:facet name="footer">
                    <p:commandButton type="button" value="Save" icon="ui-icon-check" style="margin:0" action="construction"/>
                </f:facet>
            </p:panelGrid>
        </h:panelGrid>
    </h:form>
</h:body>
</html>

I expected to go to the construction.xhtml when I press the "Save" button, but nothing happens. How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mostafa Jamareh
  • 1,389
  • 4
  • 22
  • 54
  • Is this actual code? Because a) you're using a `commandButton` for navigation and b) your `inputText`s don't have a backing value. That said, try using a `h:commandButton` or `` as explained [here](http://stackoverflow.com/a/4639230/785663). – mabi Feb 18 '14 at 19:55
  • thanks @mabi , when the user held down the save button the `under Construction` page must appear , because as you said it is not complete and it just the start of this program – Mostafa Jamareh Feb 18 '14 at 20:04
  • Why exactly did you use `type="button"`? – BalusC Feb 18 '14 at 20:36
  • thanks @BalusC, there is no special reason for that, when i saw that my command button dose not work i tried to use this – Mostafa Jamareh Feb 18 '14 at 20:39
  • Well, it's causing the whole trouble. It generates in HTML output a `` which is a dead simple push button (usually to execute some custom JS) instead of the desired `` which actually submits the form. Are you saying that you're facing **exactly the same** problem when you remove that attribute? – BalusC Feb 18 '14 at 20:47
  • yes exactly the same problem – Mostafa Jamareh Feb 18 '14 at 20:49
  • 1
    Are you absolutely sure? Are you familiar with basic HTML and HTTP? Have you checked the HTTP traffic monitor and the server log? When you remove it, then it should start firing an ajax request instead of doing absolutely nothing. Whether that ajax request would in turn trigger the navigation is just a second problem. You've there namely an input with `required="true"` without any faces message handler. – BalusC Feb 18 '14 at 20:50
  • when i use `ajax="false"` it gives me `javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation` – Mostafa Jamareh Feb 18 '14 at 20:58
  • 1
    Finally, an exception! A good exception is already a whole answer at its own. However, I can't explain that based on the code posted so far; you're not running the code as shown in the question. – BalusC Feb 18 '14 at 21:09
  • Is that caused by having no `value` for the `inputText`? I have seen this when JSF assumed `value="#{null}"`. – mabi Feb 18 '14 at 21:12
  • @BalusC i just removed `type="button"` and add `ajax="false"` – Mostafa Jamareh Feb 18 '14 at 21:14
  • Well, nothing in the code posted so far can throw that exception. I can easily explain in layman's terms why/how that exception is caused, but without a valid code snippet I can't point out what exactly in your code should be altered in order to fix that exception. Perhaps it's caused by code in the target page where you're attempting to navigate to? In any case .. You're better off posting an SSCCE. – BalusC Feb 18 '14 at 21:18
  • my program consist of to main part , core part and ui part , in the ui part i just have 2 page , first page is what i posted in the question and the another page is construction page , and i have no `managedBean` class yet in this projcet – Mostafa Jamareh Feb 18 '14 at 21:23
  • Is it the `construction` view getting properly displayed when you GET it in the browser? – Aritz Feb 19 '14 at 15:58

1 Answers1

1

when you are using commandButton you must do something like this:

<p:commandButton  value="Save" icon="ui-icon-check" style="margin:0" action="#{someBean.navigate}"/>

it means that you must use managed bean

and in your case you must use button instead of commandButton