Beginner needs help with PageActivationContext and page navigation in Tapestry
Hello, I have a page that lists job postings (beans) as follows: Template: *t:recruiters.recruiterslayout xmlns:t= http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter form t:type=form t:id=jobPostings t:grid source=jobPostings row=jobPosting add=activate,modify exclude=jobPostingValidationDate p:activatecell t:actionlink t:id=activate context=jobPosting.idJobPostingactivate/t:actionlink /p:activatecell p:modifycell t:actionlink t:id=modify context=jobPosting.idJobPostingmodify/t:actionlink /p:modifycell /t:grid /form /t:recruiters.recruiterslayout * Java: *package com.cheetah.web.pages.recruiters; import com.cheetah.domain.JobPosting; import com.cheetah.service.CheetahService; import org.apache.tapestry5.EventConstants; import org.apache.tapestry5.annotations.OnEvent; import org.apache.tapestry5.annotations.PageActivationContext; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.ioc.annotations.Inject; import java.util.Date; import java.util.List; public class JobPostingsTable { @Property private ListJobPosting jobPostings; @PageActivationContext @Property private JobPosting jobPosting; @Property private Date date; @Inject private CheetahService service; @OnEvent(EventConstants.ACTIVATE) void loadJobPostings() { jobPostings = service.loadJobPostings(); } @OnEvent(EventConstants.ACTION) void activateJobPosting() { } @OnEvent(value = EventConstants.ACTION, component = modify) Object modifyJobPosting() { return ModifyJobPosting.class; } }* However, when I click on the action link with t:id=modify, the job posting id is lost... and the ModifyJobPosting page is not able to display the bean. Template for ModifyJobPosting: *t:recruiters.recruiterslayout xmlns:t= http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter t:beandisplay object=jobPosting / /t:recruiters.recruiterslayout* java for ModifyJobPosting: *public class ModifyJobPosting { @PageActivationContext @Property private JobPosting jobPosting; }* I must be missing something obvious about PageActivationContext usage. Can anyone please help? Regards, Julien.
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Hi Julien, to call your ModifyJobPosting page from JobPostingsTable page use a page link instead of an action link. The template would look like: t:pagelink t:page=ModifyJobPosting t:context=jobPostingsmodify/t:pagelink This makes the method modifyJobPosting redundant. - http://www.winfonet.eu -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631593.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Returning page's class in a handler method you tell Tapestry where to navigate to, but yor target page needs a context. Just create a Link with context and return it instead of class. 25.07.2011, в 19:06, Julien Martin bal...@gmail.com написал(а): Hello, I have a page that lists job postings (beans) as follows: Template: *t:recruiters.recruiterslayout xmlns:t= http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter form t:type=form t:id=jobPostings t:grid source=jobPostings row=jobPosting add=activate,modify exclude=jobPostingValidationDate p:activatecell t:actionlink t:id=activate context=jobPosting.idJobPostingactivate/t:actionlink /p:activatecell p:modifycell t:actionlink t:id=modify context=jobPosting.idJobPostingmodify/t:actionlink /p:modifycell /t:grid /form /t:recruiters.recruiterslayout * Java: *package com.cheetah.web.pages.recruiters; import com.cheetah.domain.JobPosting; import com.cheetah.service.CheetahService; import org.apache.tapestry5.EventConstants; import org.apache.tapestry5.annotations.OnEvent; import org.apache.tapestry5.annotations.PageActivationContext; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.ioc.annotations.Inject; import java.util.Date; import java.util.List; public class JobPostingsTable { @Property private ListJobPosting jobPostings; @PageActivationContext @Property private JobPosting jobPosting; @Property private Date date; @Inject private CheetahService service; @OnEvent(EventConstants.ACTIVATE) void loadJobPostings() { jobPostings = service.loadJobPostings(); } @OnEvent(EventConstants.ACTION) void activateJobPosting() { } @OnEvent(value = EventConstants.ACTION, component = modify) Object modifyJobPosting() { return ModifyJobPosting.class; } }* However, when I click on the action link with t:id=modify, the job posting id is lost... and the ModifyJobPosting page is not able to display the bean. Template for ModifyJobPosting: *t:recruiters.recruiterslayout xmlns:t= http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter t:beandisplay object=jobPosting / /t:recruiters.recruiterslayout* java for ModifyJobPosting: *public class ModifyJobPosting { @PageActivationContext @Property private JobPosting jobPosting; }* I must be missing something obvious about PageActivationContext usage. Can anyone please help? Regards, Julien. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Me again, I have a typo in the pagelink (damn copy and paste). The value for the context parameter must be jobPosting of course. - http://www.winfonet.eu -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631615.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Thanks to both of you. @NilleHammer: it works with the page link. Thanks. @Igor: if I want to follow your suggestion, can I still use an actionLink or do I need an Eventlink instead? J. 2011/7/25 nillehammer tapestry.nilleham...@winfonet.eu Me again, I have a typo in the pagelink (damn copy and paste). The value for the context parameter must be jobPosting of course. - http://www.winfonet.eu -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631615.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Actually, I am not sure how to to it you way Igor. Here is what I tried: * @OnEvent(value = EventConstants.ACTION, component = modify) Object modifyJobPosting() { return componentResources.createEventLink(EventConstants.ACTION, jobPosting); } * *t:actionlink t:id=modify context=jobPosting.idJobPosting modify2/t:actionlink* However I know it does not make sense. Can you please help? Regards, Julien. 2011/7/25 Julien Martin bal...@gmail.com Thanks to both of you. @NilleHammer: it works with the page link. Thanks. @Igor: if I want to follow your suggestion, can I still use an actionLink or do I need an Eventlink instead? J. 2011/7/25 nillehammer tapestry.nilleham...@winfonet.eu Me again, I have a typo in the pagelink (damn copy and paste). The value for the context parameter must be jobPosting of course. - http://www.winfonet.eu -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631615.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
I think something like this might do the trick. @Inject private LinkSource _linkSource; Class? onActionFromModify(String contextId) { return linkSource.createPageRenderLinkWithContext(YourClass.class, contextId); } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631914.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Hello George, It seems this method does not exist... See here: http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/internal/services/LinkSource.html Regards, Julien. 2011/7/25 George Christman gchrist...@cardaddy.com I think something like this might do the trick. @Inject private LinkSource _linkSource; Class? onActionFromModify(String contextId) { return linkSource.createPageRenderLinkWithContext(YourClass.class, contextId); } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631914.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
Hi Julien LinkSource is an internal serivce, you should use PageRenderLinkSource http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PageRenderLinkSource.html#createPageRenderLinkWithContext(java.lang.Class, java.lang.Object...) regards Taha On Tue, Jul 26, 2011 at 12:22 AM, Julien Martin bal...@gmail.com wrote: Hello George, It seems this method does not exist... See here: http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/internal/services/LinkSource.html Regards, Julien. 2011/7/25 George Christman gchrist...@cardaddy.com I think something like this might do the trick. @Inject private LinkSource _linkSource; Class? onActionFromModify(String contextId) { return linkSource.createPageRenderLinkWithContext(YourClass.class, contextId); } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631914.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
opps my bad, try this import org.apache.tapestry5.Link; @Inject private LinkSource linkSource; Link onActionFromModify(String contextId) { Link link = linkSource.createPageRenderLinkWithContext(Index.class, contextId); return link; } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631991.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
It works. Thanks, J. 2011/7/25 George Christman gchrist...@cardaddy.com opps my bad, try this import org.apache.tapestry5.Link; @Inject private LinkSource linkSource; Link onActionFromModify(String contextId) { Link link = linkSource.createPageRenderLinkWithContext(Index.class, contextId); return link; } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4631991.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Beginner needs help with PageActivationContext and page navigation in Tapestry
As Taha indicated, you probable should use PageRenderLinkSource instead of LinkSource. Good luck! -- View this message in context: http://tapestry.1045711.n5.nabble.com/Beginner-needs-help-with-PageActivationContext-and-page-navigation-in-Tapestry-tp4631566p4632134.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org