Note that there are some explanatory texts on larger screens.

plurals
  1. POImplement custom authorized action wicket
    primarykey
    data
    text
    <p>I want to make authentication in my web app, when some actions occured on page. For example user click button "add to cart" and if he not yet authenticated, then signIn page displayed. After signIn it returns back to previos page. What i can use in wicket to implement this?</p> <p>P.S. On product page i have also link "buy now", which navigate to Buy page with @AuthorizeInstantiation("USER") annotation. This link work just fine.</p> <p>I think MetaDataRoleAuthorizationStrategy can be used to make the same on "add to cart". But available actions is ENABLE and RENDER only. I can add my own Action to component, but how can i associate Action with onClick() method of component?</p> <p>---Edited---</p> <p>Don't know where to write, so i edit the post. I try Christoph Leiter's solution:</p> <pre><code>add(link = new AjaxFallbackLink("add2cart") { @Override public void onClick(AjaxRequestTarget target) { if (!CynephoneSession.get().isSignedIn()) { throw new RestartResponseAtInterceptPageException(SignIn.class); } user.addItem(item.copy()); target.add(cartPanel); } }); </code></pre> <p>but after i clicked this link somehow i see ajax response with updated cartPanel in firefox. I mean it show me page with source code:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;ajax-response&gt;&lt;component id="cart2" &gt;&lt;![CDATA[&lt;div class="cart" wicket:id="cart" id="cart2"&gt; &lt;span wicket:id="total"&gt;11 800&lt;/span&gt; &lt;img src="./resource/top.Top/img/rouble-ver-1346040298957.gif"/&gt;&lt;br/&gt; &lt;img src="./resource/top.Top/img/good-ver-1346040298926.gif"/&gt;х&lt;span wicket:id="quantity"&gt;2&lt;/span&gt; &lt;/div&gt;]]&gt;&lt;/component&gt;&lt;/ajax-response&gt; </code></pre> <p>Don't understand how it pass the Exception...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload