0

My h:commandLink doesn't work. I've got a navigation rule in the faces-config.xml and a String method doSave() in my bean. I don't know why It only reloads the page without jumping into the doSave() method.

jsf-page

<h:form id="surveyForm">
    <div class="srvButton">
        <h:commandLink action="#{surveyBean.doSave}" value="#{msg.srvButton}" />
    </div>
</h:form>

faces-config

<navigation-rule>
    <from-view-id>/pages/survey.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>success</from-outcome>
        <to-view-id>/pages/surveyFinish.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

bean

public String doSave() {

    // Kundendaten speichern
    saveCustomer();     

    return "success";
}

I cleaned the content in the jsf-page for a better view, but all you need to know is the form and button I think.

yves.beutler
  • 972
  • 1
  • 14
  • 32
  • Reload might be an indicator that conversion/validation failed. Do you have a `h:messages` tag in your form? – Matt Handy Mar 30 '12 at 10:12
  • No, I've just some `h:selectOneRadio`, `t:inputText` and one `h:dataTable` tag within the form. I've got an similar webpage and there it works, but I can't find the differences – yves.beutler Mar 30 '12 at 10:51
  • Then try to add `h:messages`. It displays all validation errors and you will get more insight on what happens. – Matt Handy Mar 30 '12 at 10:52
  • I haven't got any validation methods yet, but I'll implement them as soon as I can. The error must be in a different place – yves.beutler Mar 30 '12 at 11:05
  • Did you try to run your code with the messages tag? Even if you have no validation methods, at least conversion will be performed. Can you verify that your action method is called at all (debug)? – Matt Handy Mar 30 '12 at 11:10
  • Yes, I ran it with the `h:messages` tag and there was no validation error displayed on the page. As I wanted to explain in the third sentence, the compiler doesn't jump into the action method `doSave()`. – yves.beutler Mar 30 '12 at 11:16
  • There are plenty of questions for this issue. BalusC collected the most common reasons in [this answer](http://stackoverflow.com/a/2120183/620338). – Matt Handy Mar 30 '12 at 11:19

1 Answers1

0

I just solved my problem. I replaced all my c:if tags with ui:fragment tags and it worked! Maybe, this could interest you c:foreach vs ui:repeat Thanks @matthandy for his effort..

Roger Keays
  • 3,117
  • 1
  • 31
  • 23
yves.beutler
  • 972
  • 1
  • 14
  • 32