0

i'm using JSF 2.0 and I'm having a commandButton inside div section in home.xhml. it's not working. I don't see the destinationPage, remaining only in home.xhtml.

home.xhmtl:

<div id="left_side">
    <ui:include src="login.xhtml" />
        <h:form>
           <h:commandButton value="register" action="register"/>
        </h:form>
</div>

register.xhtml is inside a h:body and a h:form

and the faces-config.xml configuration:

<navigation-rule>
    <from-view-id>home.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>register</from-outcome>
        <to-view-id>register.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>
Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
Nica
  • 55
  • 9

1 Answers1

0

If home.xhtml and register.xhtml are at the root of your application, then you need to define the navigation rule as follows:

<navigation-rule>
    <from-view-id>/home.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>register</from-outcome>
        <to-view-id>/register.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

Otherwise you add the path relative to the root.. which would be indicated by a backlash

Update

Actually in your case it seems that you do not really need the POST request which is generated by thecommandButton. A simple button which would generate a GET request seems to be sufficient:

<h:button outcome="register" value="register" /> 
Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63
  • whey are in webapp(root)/templates.. so, i've added: /templates/home.xhtml and /templates/register.xhtml.. things didn't get better.. – Nica Mar 07 '17 at 10:09
  • try out my updated answer – Maciej Kowalski Mar 07 '17 at 10:16
  • done.. now it writes on the register button: disabled because a navigation case could not be matched...the faces-config configuration is problematic ? why so ? – Nica Mar 07 '17 at 10:26
  • where did you place it? also please add the content along with web.xml – Maciej Kowalski Mar 07 '17 at 10:28
  • i've added in WEB-INF(the faces config file).. there is also web.xml(who contents: Faces Servlet /faces/* Faces Servlet .. Faces Servlet *.faces .. *.xhtml javax.faces.PROJECT_STAGE Development – Nica Mar 07 '17 at 10:59
  • sorry.. faild to edit answer that's why i've commented with the web.xml content – Nica Mar 07 '17 at 11:00
  • @BalusC.. i've updated web.xml conforming to the duplicated question but no impruvement..also, i don't have nested forms.. my div section is inside f:view.. it says: Unable to find matching navigation case with from-view-id '/list.xhtml' for action 'register' with outcome 'register'... in list.xhml is my welcome file with has the template home and home has the commandButton with register.xhmtl... – Nica Mar 07 '17 at 11:16