session handling for request object in wicket fram

2020-05-09 02:07发布

问题:

1) i have added an element in request object given below, i need to get/read this in my webpage, how can i do it?

<input type="hidden"> wicket:id="submitted" value="false" />

eg: in servlet, use request.getParameter("submitted") from hidden session.

2) in my controller class i want to set the value in session or hidden field, so that i can identify the user if he already processed the request or enetered my block of code.

回答1:

1) use HiddenField

2) use a custom WebSession object:

public class MySession extends WebSession{
    public Mysession(Request request){super(request);}
    private boolean completedRegistration;

    public boolean hasCompletedRegistration() {
        return completedRegistration;
    }

    public void setCompletedRegistration(boolean completedRegistration) {
        this.completedRegistration = completedRegistration;
    }
}


回答2:

I am not sure I have fully understood your questions.

But to make it short, if you want to get the value stored in your request object, you'll need to make the model of your input map to this value (by using HiddenField wicket internal class).

If you want to track your user, the best thing to do is looking around for a cookie set on the client side that'll allow you to manage its visits.

Please refine your question if you want a more precise answer...