On 10/23/06, Carfield Yim <[EMAIL PROTECTED]> wrote:
> On 10/23/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > Depends on what exactly you want to do. Be careful not to force
> > yourself in a procedural way of programming where you don't need to
> > (typically, 'centralized' as 'global' should ring alarm bells).
> >
>
> Yes... in fact I've do a simple web search about those topics and
> sound like wicket support these goal much difference from what I does
> before.
>
> In the past what I do is having a single servlet serve all request:
>
> doGet() {
> preprocessing();
> String actioncode = req.getParameter("code");
> componentManager.getAction(actioncode).execute();
> postprocessing();
> }
>
> I guess much applications using wicket still need similar operation,
> right? Or it is totally not that case?

Try to do without it first, and when there are specific things you
can't do, ask a question here. Components and resources  should take
care of their own cleanup etc. You don't need to directly get
parameters from the request. Rather then the code that you provide,
with Wicket you would do e.g. (Wicket 2.0 code):

class ActionLink extends Link {

  private final String action;
  @SpringBean ComponentManager componentManager;

  public ActionLink(MarkupContainer parent, String id, String action) {
    super(parent, id);
    this.action = action;
  }

  public void onClick() {
    componentManager.getAction(action).execute();
  }
}

And in fact I'm wondering what that component manager is doing anyway?
As this would be more typical:

final String someBar ...
new Link(this, "doFoo") {
  public void onClick() {
    fooHandler.doFoo(someBar);
  }
}

> > Anyway, A typical global entry point is RequestCycle, with methods
> > #onBeginRequest and #onEndRequest.  You can provide a custom request
> > cycle by providing a custom request cycle factory, which you do by
> > overriding method Application#getRequestCycleFactory.
> >
>
> So it is WebApplication.newRequestCycleProcessor().processEvents(/*
> new RequestCycle I like */)
>
> Right?

no, it's more like:

protected IRequestCycleFactory getRequestCycleFactory() {
  return new IRequestCycleFactory() {
    public RequestCycle newRequestCycle(
              Session session, Request request, Response response) {

        return new CountingRequestCycle((WebSession)session,
(WebRequest)request,
                                                (WebResponse)response);
    };
}

public class CountingRequestCycle extends WebRequestCycle {

  public CountingRequestCycle(WebSession session,
      WebRequest request, Response response) {
    super(session, request, response);
  }

  protected void onBeginRequest() {
    ((CountingWebSession) getSession()).hit();
  }
}

etc.

Eelco

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to