You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Schetinin <as...@gmail.com> on 2013/03/25 07:10:35 UTC

Navigation to a plain URL within the same application in Wicket 6

Hi,

I'm porting a Wicket application from 1.4 to 6.6, and there is one piece of
code I cannot find how to port.

In short, I have a Link descendant class that is supposed to navigate to a
manually constructed URL within the Web application -
something like "/context_path/view_path/view?viewId=21938423423"

In Wicket 1.4, I created an IRequestTarget instance with necessary
RequestParameters.
In Wicket 6.6, all these classes are not what they were in 1.4, and I don't
find an alternative.

The question is - how is it possible to do navigation to a plain URL within
the same application in Wicket 6?

Wicket 1.4 original code:

public class CustomViewLink extends Link<ViewConfiguration>{
    @Override
    public void onClick() {
        // View links do not have a click handler.
        // Instead they are dispatched by the request handling servlet.
    }
    @Override
    protected CharSequence getURL() {
        String viewBaseURI = view.getViewBaseURI();

        RequestParameters requestParameters = new RequestParameters();
        requestParameters.setPath(viewBaseURI);
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put( IViewWebDescriptor.VIEW_ID_PARAM, Long.toString(
view.getId() ) );
        requestParameters.setParameters(parameters);

        IRequestTarget target =
RequestCycle.get().getProcessor().resolve(RequestCycle.get(),
requestParameters);
        if(target == null){
            throw new WicketRuntimeException("Can't find request target for
ViewConfiguration.viewBaseURI: " + viewBaseURI);
        }
        return RequestCycle.get().urlFor(target);
    }
}

Thank you in advance,

Andrew

-- 
--
Andrew Schetinin

Re: Navigation to a plain URL within the same application in Wicket 6

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

IRequestTarget has been replaced by IRequestHandler in Wicket 1.5.0.
Check http://wicketinaction.com/2011/07/wicket-1-5-request-mapper/,
http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/ and
http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/

See whether any of the provided implementations of IRequestHandler will do
the job for you or you may need to create your own custom impl.


On Mon, Mar 25, 2013 at 8:10 AM, Andrew Schetinin <as...@gmail.com>wrote:

> Hi,
>
> I'm porting a Wicket application from 1.4 to 6.6, and there is one piece of
> code I cannot find how to port.
>
> In short, I have a Link descendant class that is supposed to navigate to a
> manually constructed URL within the Web application -
> something like "/context_path/view_path/view?viewId=21938423423"
>
> In Wicket 1.4, I created an IRequestTarget instance with necessary
> RequestParameters.
> In Wicket 6.6, all these classes are not what they were in 1.4, and I don't
> find an alternative.
>
> The question is - how is it possible to do navigation to a plain URL within
> the same application in Wicket 6?
>
> Wicket 1.4 original code:
>
> public class CustomViewLink extends Link<ViewConfiguration>{
>     @Override
>     public void onClick() {
>         // View links do not have a click handler.
>         // Instead they are dispatched by the request handling servlet.
>     }
>     @Override
>     protected CharSequence getURL() {
>         String viewBaseURI = view.getViewBaseURI();
>
>         RequestParameters requestParameters = new RequestParameters();
>         requestParameters.setPath(viewBaseURI);
>         Map<String, String> parameters = new HashMap<String, String>();
>         parameters.put( IViewWebDescriptor.VIEW_ID_PARAM, Long.toString(
> view.getId() ) );
>         requestParameters.setParameters(parameters);
>
>         IRequestTarget target =
> RequestCycle.get().getProcessor().resolve(RequestCycle.get(),
> requestParameters);
>         if(target == null){
>             throw new WicketRuntimeException("Can't find request target for
> ViewConfiguration.viewBaseURI: " + viewBaseURI);
>         }
>         return RequestCycle.get().urlFor(target);
>     }
> }
>
> Thank you in advance,
>
> Andrew
>
> --
> --
> Andrew Schetinin
>



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