> Actually 5.2 has an HttpError class you can return from the activate
> event, thus:

Cool, I missed that.

On Sat, Oct 16, 2010 at 10:55 AM, Howard Lewis Ship <hls...@gmail.com> wrote:
> Actually 5.2 has an HttpError class you can return from the activate
> event, thus:
>
>  Object onActivate(EventContext context) {
>       _context = context;
>       if (_context.getCount() == 0) return null;
>
>      return new HttpError(404, "Resource not found.");
> }
>
>
> On Sat, Oct 16, 2010 at 9:45 AM, Josh Canfield <joshcanfi...@gmail.com> wrote:
>>> Can somebody please explain how I can work around this for the novice here?
>>
>> It depends on what you wan to do.
>>
>> If you are looking to prevent tapestry from handling specific urls
>> then you can contribute to the ignored paths filter as described here:
>> http://tapestry.apache.org/tapestry5/guide/conf.html
>>
>>  public static void contributeIgnoredPathsFilter(Configuration<String>
>> configuration)
>>  {
>>    configuration.add("/dwr/.*");
>>  }
>>
>> If you just want to prevent unknown urls from the Index page then you
>> can do this really quick:
>>
>>  StreamResponse onActivate(EventContext context) {
>>        _context = context;
>>        if (_context.getCount() == 0) return null;
>>
>>        return new StreamResponse() {
>>
>>            public String getContentType() {
>>                return "";
>>            }
>>
>>            public InputStream getStream() throws IOException {
>>                return new ByteArrayInputStream(new byte[]{0});
>>            }
>>
>>            public void prepareResponse(Response response) {
>>                try {
>>                    response.sendError(404, "Page not found");
>>                } catch (IOException e) {
>>                    throw new RuntimeException("Failed to redirect?", e);
>>                }
>>            }
>>        };
>>    }
>>
>> If you think you want to do something like this from more places then
>> consider creating your own ComponentEventResultProcessor for handling
>> a custom http error type.... there is an example floating around
>> somewhere but I've run out of time to find it.
>>
>> Josh
>>
>> On Sat, Oct 16, 2010 at 2:24 AM, stephanos <stephan.beh...@gmail.com> wrote:
>>>
>>>> I think the best approach is to leverage the ignored paths mechanism.
>>>> That is early in the response processing pipeline, and will have a
>>>> good chance to ignore what should be ignored.
>>>
>>> Can somebody please explain how I can work around this for the novice here?
>>> :)
>>>
>>> Help very appreciated!
>>> --
>>> View this message in context: 
>>> http://tapestry.1045711.n5.nabble.com/No-404-error-is-raised-tp3212773p3214941.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to