From: <tri...@us...> - 2009-02-09 16:49:40
|
Revision: 1014 http://equanda.svn.sourceforge.net/equanda/?rev=1014&view=rev Author: triathlon98 Date: 2009-02-09 16:49:37 +0000 (Mon, 09 Feb 2009) Log Message: ----------- EQ-297 navigation module, PageWithTitle interface, extra NavigationManager options Modified Paths: -------------- trunk/equanda-maven-plugin/src/main/resources/archetype-resources/pom.xml trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/internal/NavigationManagerImpl.java trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/services/NavigationManager.java trunk/equanda-t5navigation/src/site/wiki/index.wiki Added Paths: ----------- trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/PageWithTitle.java Modified: trunk/equanda-maven-plugin/src/main/resources/archetype-resources/pom.xml =================================================================== --- trunk/equanda-maven-plugin/src/main/resources/archetype-resources/pom.xml 2009-02-09 11:39:37 UTC (rev 1013) +++ trunk/equanda-maven-plugin/src/main/resources/archetype-resources/pom.xml 2009-02-09 16:49:37 UTC (rev 1014) @@ -290,6 +290,11 @@ </dependency> <dependency> <groupId>org.equanda</groupId> + <artifactId>equanda-t5navigation</artifactId> + <version>#literal()${equanda-version}#end</version> + </dependency> + <dependency> + <groupId>org.equanda</groupId> <artifactId>equanda-t5gui</artifactId> <version>#literal()${equanda-version}#end</version> </dependency> Added: trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/PageWithTitle.java =================================================================== --- trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/PageWithTitle.java (rev 0) +++ trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/PageWithTitle.java 2009-02-09 16:49:37 UTC (rev 1014) @@ -0,0 +1,40 @@ +/** + * This file is part of the equanda project. + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF + * ANY KIND, either express or implied. See the License for the specific language governing rights and + * limitations under the License. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + */ + +package org.equanda.t5nav; + +/** + * Marker interface which indicates that the page title can be queried. + * + * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a> + */ +public interface PageWithTitle +{ + /** + * Get the title for this page. This title will typically be used to refer to this page in a breadcrumbs component. + * + * @return page title + */ + String getTitle(); +} Modified: trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/internal/NavigationManagerImpl.java =================================================================== --- trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/internal/NavigationManagerImpl.java 2009-02-09 11:39:37 UTC (rev 1013) +++ trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/internal/NavigationManagerImpl.java 2009-02-09 16:49:37 UTC (rev 1014) @@ -24,7 +24,10 @@ package org.equanda.t5nav.internal; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.runtime.Component; import org.apache.tapestry5.services.ApplicationStateManager; +import org.equanda.t5nav.PageWithTitle; import org.equanda.t5nav.services.*; /** @@ -68,6 +71,26 @@ return context; } + + public NavigationContext beginNavigation( NavigationTarget returnTarget ) + { + NavigationContext context = beginNavigation( true ); + context.setReturnTarget( returnTarget ); + return context; + } + + public NavigationContext beginNavigation( ComponentResources resources ) + { + NavigationContext context = beginNavigation( true ); + String pageName = resources.getPageName(); + String title = pageName; + Component page = resources.getPage(); + if ( page instanceof PageWithTitle ) title = ( (PageWithTitle) page ).getTitle(); + context.setReturnTarget( + new NavigationTargetImpl( resources.createPageLink( pageName, false ), title ) ); + return context; + } + /** * creates a NavigationTracker if it does not already exist within * the session. The ApplicationStateManager is used to persist the Modified: trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/services/NavigationManager.java =================================================================== --- trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/services/NavigationManager.java 2009-02-09 11:39:37 UTC (rev 1013) +++ trunk/equanda-t5navigation/src/main/java/org/equanda/t5nav/services/NavigationManager.java 2009-02-09 16:49:37 UTC (rev 1014) @@ -24,6 +24,8 @@ package org.equanda.t5nav.services; +import org.apache.tapestry5.ComponentResources; + /** * The navigation manager is used to start and end navigation contexts (like conversations) * @@ -37,7 +39,7 @@ * * @return newly created navigation context */ - public NavigationContext beginNavigation(); + NavigationContext beginNavigation(); /** * creates a new navigation. You can choose whether navigations are "chained", that is whether you can get back @@ -46,7 +48,7 @@ * @param chain should the current mini-conversation be restored when the new one is invalidated * @return newly created navigation context */ - public NavigationContext beginNavigation( boolean chain ); + NavigationContext beginNavigation( boolean chain ); /** * Creates a new "chained" navigation, specifying the link and title of the return page. @@ -55,13 +57,29 @@ * @param title title for the link page, to display in breadcrumbs components * @return newly created navigation context */ - public NavigationContext beginNavigation( Object link, String title ); + NavigationContext beginNavigation( Object link, String title ); /** + * Creates a new "chained" navigation, specifying the link and title of the return page. + * + * @param returnTarget intended return target + * @return newly created navigation context + */ + NavigationContext beginNavigation( NavigationTarget returnTarget ); + + /** + * Creates a new "chained" navigation, specifying the link and title of the return page. + * + * @param resources ComponentResources used for obtaining return link and page name + * @return newly created navigation context + */ + NavigationContext beginNavigation( ComponentResources resources ); + + /** * ends a mini-conversation * * @param navigation to invalidate * @return redirect target if there was one */ - public Object endNavigation( NavigationContext navigation ); + Object endNavigation( NavigationContext navigation ); } \ No newline at end of file Modified: trunk/equanda-t5navigation/src/site/wiki/index.wiki =================================================================== --- trunk/equanda-t5navigation/src/site/wiki/index.wiki 2009-02-09 11:39:37 UTC (rev 1013) +++ trunk/equanda-t5navigation/src/site/wiki/index.wiki 2009-02-09 16:49:37 UTC (rev 1014) @@ -18,6 +18,9 @@ {code} @Inject +private ComponentResources resources; + +@Inject private NavigationManager navigationManager; @InjectPage @@ -31,7 +34,30 @@ } {code} +This can also be done shorter if your page class implements "PageWithTitle". +{code} +@Inject +private ComponentResources resources; + +@Inject +private NavigationManager navigationManager; + +@InjectPage +private PageB pageB; + +public String getTitle() { + return "title for return link"; +} + +Object onActionFromPageBNavigation() +{ + navigationManager.beginNavigation( resources ); + return pageB; +} +{code} + + h3. Go to another page, creating a new navigation context, not chained {code} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |