You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Kriesten <kr...@mail.footprint.de> on 2009/03/23 05:20:18 UTC

handling not mounted URLs

Hi,

I've set up a Wicket application as ROOT with URL pattern /* and have some
mounts on it.

Now I want all unmounted stuff handled thru the Homepage-class (i.e. get the
path-info for a redirect). Is there a way to do this?

ATM, I get a "404 : /test/ was not found on this server." when calling
http://localhost:8080/test/

Best regards, --- Jan.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Jan Kriesten <kr...@mail.footprint.de>.
Hi Brill,

> Ahh... are you try to set up an RESTful type of URI where the path is
> relevant to the request being executed?

no, not really, my usecase is much simpler. :) If I encounter an unmounted path
I just want to create a frameset which has a target on another server. And the
target url should get the pathinfo appended.

> Hmm... how about a IRequestTargetUrlCodingStrategy?

I first thought to go that way, just that you can't mount '/' - so that's no
option either.

Best regards, --- Jan.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Brill Pappin <br...@pappin.ca>.
Ahh... are you try to set up an RESTful type of URI where the path is  
relevant to the request being executed?

I had to do something like that for an images resource recently...  
although it may be more at the mercy of Wicket than what you need.

Hmm... how about a IRequestTargetUrlCodingStrategy?
This is on the verge of guessing now, but i think it will allow you to  
mount it and then check if you want to process the request with it.

What I used it for was some Apple javascript (Dashcode stuff) that was  
being insistent on the paths it used for its resources and which  
didn't match those used for a Wicket resource.
The coding strategy would essentially checked if the path began with  
some known value, and then used a PackageResourceStream to load the  
wicketized version of the content.

The code for the strategy is below in case it gives you the clues you  
need to resolve your issue.

- Brill

public class IPhoneImageRequestTargetUrlCodingStrategy implements
		IRequestTargetUrlCodingStrategy {

	@Override
	public IRequestTarget decode(RequestParameters requestParameters) {
		String path = requestParameters.getPath();
		ResourceStreamRequestTarget target = new ResourceStreamRequestTarget(
				new PackageResourceStream(DashboardPage.class, path));
		return target;
	}

	@Override
	public CharSequence encode(IRequestTarget requestTarget) {
		return null;
	}

	@Override
	public String getMountPath() {
		return "Images";
	}

	@Override
	public boolean matches(IRequestTarget requestTarget) {
		return false;
	}

	public boolean matches(String path) {
		return path.startsWith("Images/") && path.endsWith(".png");
	}

	@Override
	public boolean matches(String path, boolean arg1) {
		return matches(path);
	}

}






On 23-Mar-09, at 1:12 AM, Jan Kriesten wrote:

>
> Hi Brill,
>
>> what about setting up an "error page" using the standard servlet  
>> method
>> that points to a wicket page?
>
> the point is: you will still get a 404 error code for the page  
> (which the
> user/search engine shouldn't, since it's not an error).
>
> Best regards, --- Jan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Jan Kriesten <kr...@mail.footprint.de>.
Hi Jeremy,

> Maybe I'm just sleepy - but where did you put that code?  It's not java.

heh - that's Scala. :-)

The code belongs to the HomePage class.

Best regards, --- Jan.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Maybe I'm just sleepy - but where did you put that code?  It's not java.




On Mon, Mar 23, 2009 at 1:00 AM, Jan Kriesten <kr...@mail.footprint.de>wrote:

>
> Hi Jeremy,
>
> > Can you mount another filter that, if Wicket does not respond, instead
> > responds with either a valid page or a redirect back to a valid Wicket
> page?
>
> no, that's no option. I got the ErrorPage-Version working in the way that I
> manually set the status code with
>
> val uri = req.getAttribute( "javax.servlet.error.request_uri"
> ).asInstanceOf[String]
> if( uri!=null ) {
>  val res = getResponse.asInstanceOf[WebResponse].getHttpServletResponse
>  res.setStatus( 200 )
> }
>
> That way you get a 200 on the client.
>
> Best regards, --- Jan.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: handling not mounted URLs

Posted by Jan Kriesten <kr...@mail.footprint.de>.
Hi Jeremy,

> Can you mount another filter that, if Wicket does not respond, instead
> responds with either a valid page or a redirect back to a valid Wicket page?

no, that's no option. I got the ErrorPage-Version working in the way that I
manually set the status code with

val uri = req.getAttribute( "javax.servlet.error.request_uri" ).asInstanceOf[String]
if( uri!=null ) {
  val res = getResponse.asInstanceOf[WebResponse].getHttpServletResponse
  res.setStatus( 200 )
}

That way you get a 200 on the client.

Best regards, --- Jan.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Can you mount another filter that, if Wicket does not respond, instead
responds with either a valid page or a redirect back to a valid Wicket page?

--
Jeremy Thomerson
http://www.wickettraining.com



On Mon, Mar 23, 2009 at 12:12 AM, Jan Kriesten
<kr...@mail.footprint.de>wrote:

>
> Hi Brill,
>
> > what about setting up an "error page" using the standard servlet method
> > that points to a wicket page?
>
> the point is: you will still get a 404 error code for the page (which the
> user/search engine shouldn't, since it's not an error).
>
> Best regards, --- Jan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: handling not mounted URLs

Posted by Jan Kriesten <kr...@mail.footprint.de>.
Hi Brill,

> what about setting up an "error page" using the standard servlet method
> that points to a wicket page?

the point is: you will still get a 404 error code for the page (which the
user/search engine shouldn't, since it's not an error).

Best regards, --- Jan.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: handling not mounted URLs

Posted by Brill Pappin <br...@pappin.ca>.
what about setting up an "error page" using the standard servlet  
method that points to a wicket page?

There are a few different ways you can capture errors:

in the web.xml for instance you can use a construct something like  
(check the syntax):

  <error-page>
         <exception-type>javax.servlet.ServletException</exception-type>
         <location>/mypath</location>
     </error-page>

of to capture an HTTP error:

<error-page>
	<error-code>404</error-code>
	<location>/mypath</location>
</error-page>

So just mount a page at that path and your page should get called when  
you get an error.



- Brill

On 23-Mar-09, at 12:20 AM, Jan Kriesten wrote:

>
> Hi,
>
> I've set up a Wicket application as ROOT with URL pattern /* and  
> have some
> mounts on it.
>
> Now I want all unmounted stuff handled thru the Homepage-class (i.e.  
> get the
> path-info for a redirect). Is there a way to do this?
>
> ATM, I get a "404 : /test/ was not found on this server." when calling
> http://localhost:8080/test/
>
> Best regards, --- Jan.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org