Singh,

Take a look at  http://cwiki.apache.org/WICKET/url-coding-strategies.html
HybridUrlCodingStrategy .

Regards - Cemal
http://www.jWeekend.co.uk http://jWeekend.co.uk 


Singh Mukesh wrote:
> 
> 
> Hi,
> 
> I am using wicket. I have a page with one links which increase the counter
> value based on user click on the link, for all these actions I am using
> Ajax. For instance user click 5 times on link the counter shows value 5.
> It is ok but if I click on browsers refresh button all changes are lost
> and it shows the counter value 0 instead of 5. How to handle the refresh
> button?
> 
> Please find the code below.
> 
> TestPage.java
> 
> import org.apache.wicket.PageParameters;
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.markup.html.AjaxLink;
> import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.markup.html.basic.Label;
> import org.apache.wicket.model.IModel;
> import org.apache.wicket.model.Model;
> 
> public class TestPage extends WebPage {
>       
>       public TestPage(PageParameters parameters) {
>               super(parameters);
>               final Model<Integer> modell = new Model<Integer>(new 
> Integer(0));
>               // Slik at telleverdien legges i session
>               setDefaultModel(modell);
>               final Label telleLabel = new Label("teller", modell);
>               telleLabel.setOutputMarkupId(true);
>               final Label hashcodeLabel = new Label("hashcode", new 
> IModel<String>() {
>                       private static final long serialVersionUID = 1L;
> 
>                       public String getObject() {
>                               return 
> String.valueOf(System.identityHashCode(TestPage.this));
>                       }
> 
>                       public void setObject(String object) {
>                               /* NOOP */
>                       }
> 
>                       public void detach() {
>                               /* NOOP */
>                       }
>                       
>               });
>               hashcodeLabel.setOutputMarkupId(true);
>               add(telleLabel);
>               add(new AjaxLink<Integer>("link", modell) {
>                       private static final long serialVersionUID = 1L;
> 
>                       @Override
>                       public void onClick(AjaxRequestTarget target) {
>                               // Øk det delte modellobjektet
>                               Integer tall = getModelObject();
>                               int verdi = tall.intValue() + 1;
>                               tall = new Integer(verdi);
>                               setModelObject(tall);
>                               // Fortell klienten hvilken komponent som skal 
> oppdateres
>                               target.addComponent(telleLabel);
>                               target.addComponent(hashcodeLabel);
>                       }               
>               });
>               add(hashcodeLabel);
>               add(new AjaxCheckBox("versioned", new 
> Model<Boolean>(Boolean.TRUE)) {
>                       private static final long serialVersionUID = 1L;
> 
>                       @Override
>                       protected void onUpdate(AjaxRequestTarget target) {
>                               
> setVersioned(this.getModelObject().booleanValue());
>                       }
>                       
>               });
>               setVersioned(true);
>       }
>       
>       
> 
>       
> }
> 
> 
> 
> TestApplication.java
> 
> import org.apache.wicket.Page;
> import org.apache.wicket.Request;
> import org.apache.wicket.Response;
> import org.apache.wicket.Session;
> import org.apache.wicket.protocol.http.WebApplication;
> 
> public class TestApplication extends WebApplication {
> 
>       @Override
>       public Class<? extends Page> getHomePage() {
>               return TestPage.class;
>       }
>       
> }
> 
> TestPage.html 
> 
> <html
>       xmlns="http://www.w3.org/1999/xhtml";  
>       xmlns:wicket="http://wicket.apache.org/";>
> <!-- Basis-side som inneholder navigasjonssti -->
>       <head>
>       <title>Testside</title>
> </head>
> <body>
>        # + &nbsp;0
>       <p class="portlet-font">Denne portleten har hashCode lik 34563.</p>
>       <p class="portlet-font"><input type="checkbox" 
> class="portlet-form-field"
> wicket:id="versioned"> Versjonert</p>
> </body>
> </html>
> 
> 
> Please suggest me the way how to handle the refresh button problem.
> 
> Please do the needful.
> 
> 
> Med vennlig hilsen
> 
> MUKESH SINGH
> CAPGEMINI Consultant
> Arrive AS
> T (+47) 46 47 90 16
> E-post: [EMAIL PROTECTED]
> http://servicedesk.arrive.no
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/page-refresh-cleans-my-page-state-tp20598492p20601031.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to