Seam page navigation with includes
I'm using seam page navigation rules. and did not experience any problem with adding rules which redirect from one page to another. But since I designed my page views using those redirection simply don't happen anymore for those pages. Tried to define the rule to the view that gets included, then to the view that includes the others (which to me was making more sense) bu开发者_Go百科t none work. Is there anything special about page navigation in seam using included view-id ?
main.xhtml:
<h:outputLabel value="Details:"/>`
<a4j:include viewId="contacts.xhtml" id="contactsDetails"/>`
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
I'm using jsf, xhtml as my page views.
Thanks
Its difficult for me to answer this question because I simply don't understand it. However I will try to guess what you are asking.
You have a page ie: /somePage.xhtml
and inside that page you include some other pages.
I tend to write all my page navigation in pages.xml
. I like having everything in one place, because it makes things cleaner and easier to maintain.
You can use wildcards also in the pages.xml
file.
So you can do something like this.
<page login-required="true" view-id="/admin/*">
<restrict>#{s:hasRole('orgadmin') or s:hasRole('sysadmin')}</restrict>
<navigation from-action="#{userAdmin.editUser}">
<redirect view-id="/admin/create_user.xhtml" />
</navigation>
<navigation from-action="#{applicationProcessAdmin.saveScheme}">
<rule if-outcome="failure">
<redirect view-id="/admin/processes.xhtml" />
</rule>
</navigation>
</page>
In the above example, I am using a wildcard to say that all navigation that happens from /admin/* that uses some specific action, should redirect to some page i have.
You can also be very specific with the pages
<page login-required="true" view-id="/officer/admin/contacts.xhtml">
<begin-conversation join="true" />
<navigation from-action="#{officerAdmin.saveContact}">
<redirect/>
</navigation>
</page>
If this doesn't help you, you need to clarify your question better.
Update
Try changing your
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
To this instead
<page view-id="/*" login-required="true">
<navigation from-action="#{myBean.readyToSee}">
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
UPDATE 2
Does all your navigation fail? Or is it only some?
Try removing the /*
on page view and replace with just *
If you do this will work:
@Name("myBean")
public class MyBean {
public String doSomething() {
return "success";
}
}
Now from your xhtml (Does not matter which include page it is from)
<!-- Depending on what button you are using, <h:form> is mandatory -->
<h:form>
<h:commandButton value="TEST" action="#{myBean.doSomething}" />
</h:form>
And in your pages xml
<page view-id="*">
<navigation from-action="#{myBean.doSomething}">
<rule if-outcome="success">
<redirect view-id="/test.xhtml" />
</rule>
</navigation>
</page>
The above will work. If it does not, the error is somewhere else in your code.
精彩评论