开发者

JSF2 how to automatically navigate, based on a value

开发者 https://www.devze.com 2023-01-29 08:23 出处:网络
In JSF2, I was wondering how I could navigate to a page automatically based on a value - automatically meaning, without having to click a button or commandLink?

In JSF2, I was wondering how I could navigate to a page automatically based on a value - automatically meaning, without having to click a button or commandLink?

I have a composite component with parameters (composite:attribute) and when this composite component is started, I would like user to be automatically navigated (without user having to press a button or click on a command link) to a certain page, based on one of the composite:attributes. How could I do this?

Essentially, is there a way to get a JSF .xhtml page to output an action value automatically - so that this value could be used for navigating to a specific page?

My composite component's interface looks like this: (I have simplified things here to get the idea across)

<composite:interface>
<composite:attribute name="showTable2" type="Boolean"
    required="true" shortDescription="Show the second table?" />
</composite:interface>

And I have a navigation rule like this, where the user is taken to a page based on the input composite:attribute. The thing is that, user needs to be taken to one of the two pages in the navigation rule because that page is the one that user would get to see first. So, no button / commandLink to use for executing this navigation rule.

<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
    <from-outcome>showTable2<开发者_StackOverflow;/from-outcome>
    <to-view-id>/twoTables.xhtml</to-view-id>
</navigation-case>
<navigation-case>
    <from-outcome>dontShowTable2</from-outcome>
    <to-view-id>/oneTable.xhtml</to-view-id>
</navigation-case>

So, the input composite:attribute needs to be converted into an outcome value and be executed so that my navigation rule can be executed.

Thanks a lot!


In Seam Faces exists the viewAction component that trigers an action during one the phases proceeding the render response.

Here is the link: http://docs.jboss.org/seam/3/faces/latest/reference/en-US/html_single/#viewaction

0

精彩评论

暂无评论...
验证码 换一张
取 消