Re: Using PageReference for a 'back' link

2012-10-23 Thread Dirk Forchel
Here a short example with two Pages (a kind of overview page and a
detailed view page) how it could work:

e.g. in OverviewPage.java:



in DetailedViewPage.java:






--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212p4653235.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using PageReference for a 'back' link

2012-10-23 Thread Martin Grigorov
Hi,

The question was how to use PageReference with BookmarkablePageLink.

To do this the current page id can be passed as a parameter to the next page.

add(new BookmarkablePageLink(id).getPageParameters().add(prevPageId,
getPage().getPageId()));

In the NextPage.java do:

PageReference prev = new
PageReference(getPageParameters().get(prevPageId).toInteger());

On Tue, Oct 23, 2012 at 9:41 AM, Dirk Forchel dirk.forc...@exedio.com wrote:
 Here a short example with two Pages (a kind of overview page and a
 detailed view page) how it could work:

 e.g. in OverviewPage.java:



 in DetailedViewPage.java:






 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212p4653235.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using PageReference for a 'back' link

2012-10-23 Thread Leonardo D'Alimonte
Hello Dirk,

thanks for the quick reply.

BookmarkablePageLink doesn't allow overriding of onClick behaviour, so I
don't know if I can implement a custom bookmarkable link the way you
described... :)

I attach down here an example of what I described before:

In MyPage.class I wnat to add the link below:

add(new BookmarkablePageLink(accertamento,
AccertamentoSerbatoiPage.class));

and inside AccertamentoSerbatoiPage.class I would link a link that points
back to MyPagehow can I pass the PageReference of MyPage inside that
constructor?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212p4653248.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using PageReference for a 'back' link

2012-10-23 Thread Martijn Dashorst
Think for a moment about what you are asking: a bookmarkable page link
with a session relative component. Bookmarkable page link's URLs are
*bookmarkable*. They can be stored in favorites, and opened two
seconds, two weeks or two years from now.

What does the page ID point to in 2 weeks? Or 2 years from now?
Bookmarkable links and session relative stuff don't mix.

So instead of encoding such in the URL, why not let your base page (or
something similar) query the page store for a page of a certain type,
and get a page reference to that.

Martijn


 Mon, Oct 22, 2012 at 6:03 PM, Leonardo D'Alimonte
leonardo.dalimo...@loginet.it wrote:
 Hi,

 I'm working on the migration of our project from Wicket 1.4 to Wicket 1.5
 and I'm trying to fix support of a 'back' link, that before was implemented
 using PageMap and now.well, PageMap are gone!

 I read on different forums that PageReference could be an answer to my
 problem by calling inside onClick method
 setResponsePage(pageReference.getPage())but I cannot still understand
 how I can pass a PageReference to a BookmarkablePageLink.

 Is there a quick way to build a 'back' link with Wicket 1.5?

 Thanks in advance for your answer!

 Leonardo



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using PageReference for a 'back' link

2012-10-23 Thread Dirk Forchel
Sorry, I did not read your question carefully. Yes my suggestion does not
work with BookmarkablePageLinks.
But Martin has given you already the right solution.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212p4653257.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using PageReference for a 'back' link

2012-10-23 Thread Martin Grigorov
On Tue, Oct 23, 2012 at 12:40 PM, Martijn Dashorst
martijn.dasho...@gmail.com wrote:

 Think for a moment about what you are asking: a bookmarkable page link
 with a session relative component. Bookmarkable page link's URLs are
 *bookmarkable*. They can be stored in favorites, and opened two
 seconds, two weeks or two years from now.

 What does the page ID point to in 2 weeks? Or 2 years from now?
 Bookmarkable links and session relative stuff don't mix.

 So instead of encoding such in the URL, why not let your base page (or
 something similar) query the page store for a page of a certain type,
 and get a page reference to that.

Unfortunately the world is not perfect ..

Using BookmarkablePageLink or just Link is the same if the target page
is stateful, i.e. has the pageId parameter in the produced url.
The benefit is that BPL does one http redirect less then when using Link.

Bookmarking the target page doesn't know anything about the current
session/state by itself.
The only problem is when you bookmark a url like:
.../wicket/page?pageId  This may or may not be resolved to a page
if requested after 2 years. The real problem is if it is resolved then
most probably it is not the right page.
If the url is .../my/mount/path?pageId... then you will go to the
wanted page, just in its initial state.


 Martijn


  Mon, Oct 22, 2012 at 6:03 PM, Leonardo D'Alimonte
 leonardo.dalimo...@loginet.it wrote:
 Hi,

 I'm working on the migration of our project from Wicket 1.4 to Wicket 1.5
 and I'm trying to fix support of a 'back' link, that before was implemented
 using PageMap and now.well, PageMap are gone!

 I read on different forums that PageReference could be an answer to my
 problem by calling inside onClick method
 setResponsePage(pageReference.getPage())but I cannot still understand
 how I can pass a PageReference to a BookmarkablePageLink.

 Is there a quick way to build a 'back' link with Wicket 1.5?

 Thanks in advance for your answer!

 Leonardo



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Using-PageReference-for-a-back-link-tp4653212.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org