onNodeSelect Navigation rule

UI Components for JSF
Post Reply
bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

18 Aug 2010, 13:10

I have been trying to figure out how to get a navigation rule working based on the Tree example.
I have the Tree with items and a onNodeSelect event which works because i can see it updates the bean and also the logging shows that it gets into this event.

My onNodeSelect does this.

Code: Select all

	public String onNodeSelect(NodeSelectEvent event) {
		
		if ( event.getTreeNode().getChildCount() == 0 ) {
			
			if ( event.getTreeNode().toString().equals("Unknown") ) {
				this.currentNode = "Unknown Messages" ;
			} else {
				this.currentNode =  event.getTreeNode().getParent().toString() + " - " + event.getTreeNode().toString() ;
			}
			logger.log(Level.INFO, "show_messages");
			return "show_messages";
		} else
		{
			return "";
		}
	}}
My navigation rule is:

Code: Select all

	<navigation-rule>
		<display-name>*</display-name>
		<from-view-id>*</from-view-id>
		<navigation-case>
			<from-outcome>show_messages</from-outcome>
			<to-view-id>/ui/msglist.xhtml</to-view-id>
		</navigation-case>
	</navigation-rule>
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2010, 13:32

It is not supported now but easy to implement as we've done it for datatable row selection, feel free to create a feature request for this.

bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

18 Aug 2010, 13:40

Thanks Optimus.

I was thinking this was default JSF behavior. For the time being is there a workaround?

And how would i go about making this a feature request?
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2010, 13:42

Are you using JSF 1.2 or JSF 2.0? For JSF 2.0 I think there is.

bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

18 Aug 2010, 13:45

I am using JSF 2.0 (Mojarra 2.0.2).
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2010, 13:47

Ok, so maybe you can try;

Code: Select all

FacesContext context = FacesContext.getCurrentInstance();
NavigationHandler navHandler = context.getApplication().getNavigationHandler();
navHandler.handleNavigation(context, null, "show_messages");
Also you need to add <redirect /> to your navigation rule. This should definitely work in 2.2 but should work for 2.1 I hope.

bornsilly
Posts: 27
Joined: 19 Mar 2010, 15:41
Location: Netherlands

18 Aug 2010, 14:00

Optimus,

That worked great! I am using PrimeFaces 2.1.

Thanks a lot.
PrimeFaces 3.3.4, Primefaces-extensions 0.6.0, JBoss 7.1, Mojarra 2.1.10

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Aug 2010, 00:43

Good to hear, we might add it as a built-in feature and integrate this listener with navigation rules in the future if there is more request.

yhrchan
Posts: 11
Joined: 03 Sep 2010, 17:40

03 Sep 2010, 17:42

is it possible for you to provide more info on your implementation? I am kinda new to this and I have been having a hard time trying to figure out a way to put commandLinks into the nodes of the tree and I can't get it to work so far...

kanikman
Posts: 111
Joined: 20 Nov 2009, 02:53
Location: Poland
Contact:

23 Nov 2010, 00:28

More request. So my request is the same. All clickable elements should implement action. this is the basic bahvor , I think.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 31 guests