Clean URL Parameters

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Clean URL Parameters

Mikko Saarela
Hi,

I'm getting a Stripes validation error report after going to URL:

http://www.myserver.com/my-app/some/1

"The value (1) entered in field My Value must be a valid number"

I have clean URLs configured.

My ActionBean is like this:

@UrlBinding("/some/{myValue}")
public class SomeActionBean implements ActionBean {
    private ActionBeanContext context;

    @Validate(converter=IntegerTypeConverter.class)
    private int myValue;
   
    @DefaultHandler
    public Resolution view() {
       
        System.out.println(myValue);
        return new ForwardResolution("some.jsp");
    }
   
    @Override
    public ActionBeanContext getContext() {
        return context;
    }

    @Override
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    public int getMyValue() {
        return myValue;
    }

    public void setMyValue(int myValue) {
        this.myValue = myValue;
    }
}

The full error message was:
"Here's how it is. Someone (quite possibly the Stripes Dispatcher) needed to
get the source page resolution. But no source page was supplied in the
request, and unless you override ActionBeanContext.getSourcePageResolution()
you're going to need that value. When you use a <stripes:form> tag a hidden
field called '_sourcePage' is included. If you write your own forms or links
that could generate validation errors, you must include a value for this
parameter. This can be done by calling request.getServletPath()."


Any ideas how to get this working?





------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

VANKEISBELCK Remi
Hi Mikko,

You hit the URL directly : when stripes validates it fails on integer conversion, and then tries to foward to the _sourcePage param which doesn't exist...

<s:link/> and <s:form/> both generate the source page param.

Otoh I don't understand why "1" doesn't convert to an int... have you tried to remove completely the @Validate on myValue ? Stripes should type convert automatically here.

HTH

Remi

 


Le 4 avr. 2013 à 13:10, Mikko Saarela a écrit :

> Hi,
>
> I'm getting a Stripes validation error report after going to URL:
>
> http://www.myserver.com/my-app/some/1
>
> "The value (1) entered in field My Value must be a valid number"
>
> I have clean URLs configured.
>
> My ActionBean is like this:
>
> @UrlBinding("/some/{myValue}")
> public class SomeActionBean implements ActionBean {
>    private ActionBeanContext context;
>
>    @Validate(converter=IntegerTypeConverter.class)
>    private int myValue;
>
>    @DefaultHandler
>    public Resolution view() {
>
>        System.out.println(myValue);
>        return new ForwardResolution("some.jsp");
>    }
>
>    @Override
>    public ActionBeanContext getContext() {
>        return context;
>    }
>
>    @Override
>    public void setContext(ActionBeanContext context) {
>        this.context = context;
>    }
>
>    public int getMyValue() {
>        return myValue;
>    }
>
>    public void setMyValue(int myValue) {
>        this.myValue = myValue;
>    }
> }
>
> The full error message was:
> "Here's how it is. Someone (quite possibly the Stripes Dispatcher) needed to
> get the source page resolution. But no source page was supplied in the
> request, and unless you override ActionBeanContext.getSourcePageResolution()
> you're going to need that value. When you use a <stripes:form> tag a hidden
> field called '_sourcePage' is included. If you write your own forms or links
> that could generate validation errors, you must include a value for this
> parameter. This can be done by calling request.getServletPath()."
>
>
> Any ideas how to get this working?
>
>
>
>
>
> ------------------------------------------------------------------------------
> Minimize network downtime and maximize team effectiveness.
> Reduce network management and security costs.Learn how to hire
> the most talented Cisco Certified professionals. Visit the
> Employer Resources Portal
> http://www.cisco.com/web/learning/employer_resources/index.html
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

Mikko Saarela
> You hit the URL directly : when stripes validates it fails on integer
conversion, and then tries to foward to
> the _sourcePage param which doesn't exist...
>
> <s:link/> and <s:form/> both generate the source page param.
>
> Otoh I don't understand why "1" doesn't convert to an int... have you
tried to remove completely the
>  <at> Validate on myValue ? Stripes should type convert automatically
here.

Hi Remi,

I tried without the @Validate annotation, with exactly the same result.

I also tried to use it with a Stripes link-tag like this:

<stripes:link beanclass="com.myserver.SomeActionBean">
    <stripes:param name="myValue" value="5"/>
    The Link
</stripes:link>

... also same result.


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

Poitras Christian
Hi,

Clean URL works well for me.
Does it work if you remove "{myValue}" from the UrlBinding?

Christian

-----Message d'origine-----
De : Mikko Saarela [mailto:[hidden email]]
Envoyé : April-04-13 9:01 AM
À : [hidden email]
Objet : Re: [Stripes-users] Clean URL Parameters

> You hit the URL directly : when stripes validates it fails on integer
conversion, and then tries to foward to
> the _sourcePage param which doesn't exist...
>
> <s:link/> and <s:form/> both generate the source page param.
>
> Otoh I don't understand why "1" doesn't convert to an int... have you
tried to remove completely the
>  <at> Validate on myValue ? Stripes should type convert automatically
here.

Hi Remi,

I tried without the @Validate annotation, with exactly the same result.

I also tried to use it with a Stripes link-tag like this:

<stripes:link beanclass="com.myserver.SomeActionBean">
    <stripes:param name="myValue" value="5"/>
    The Link
</stripes:link>

... also same result.


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

VANKEISBELCK Remi
In reply to this post by Mikko Saarela
Just tried it out of curiosity and reproduced the problem.

The issue disappears if you have a real JSP to forward to and everything works as expected.

Then if you have a fictious JSP with path starting by "/" you have another error (a 404, which is expected). But you have the same "source page not found" error if the path doesn't start by "/".

Definitely looks like a bug : you should have a 404 instead of a validation error.  

Mikko, you can workaround by forwarding to an actual JSP page (we usually toss them under WEB-INF in order to make them available only using intenal forwards via ForwardResolution : we usually only expose ActoinBeans, not JSPs). You don't need to tell Stripes which converter to use, int is built-in.

I'm gonna file a bug and test case. Thanks for the report.

Cheers

Remi


Le 4 avr. 2013 à 13:10, Mikko Saarela a écrit :

> Hi,
>
> I'm getting a Stripes validation error report after going to URL:
>
> http://www.myserver.com/my-app/some/1
>
> "The value (1) entered in field My Value must be a valid number"
>
> I have clean URLs configured.
>
> My ActionBean is like this:
>
> @UrlBinding("/some/{myValue}")
> public class SomeActionBean implements ActionBean {
>    private ActionBeanContext context;
>
>    @Validate(converter=IntegerTypeConverter.class)
>    private int myValue;
>
>    @DefaultHandler
>    public Resolution view() {
>
>        System.out.println(myValue);
>        return new ForwardResolution("some.jsp");
>    }
>
>    @Override
>    public ActionBeanContext getContext() {
>        return context;
>    }
>
>    @Override
>    public void setContext(ActionBeanContext context) {
>        this.context = context;
>    }
>
>    public int getMyValue() {
>        return myValue;
>    }
>
>    public void setMyValue(int myValue) {
>        this.myValue = myValue;
>    }
> }
>
> The full error message was:
> "Here's how it is. Someone (quite possibly the Stripes Dispatcher) needed to
> get the source page resolution. But no source page was supplied in the
> request, and unless you override ActionBeanContext.getSourcePageResolution()
> you're going to need that value. When you use a <stripes:form> tag a hidden
> field called '_sourcePage' is included. If you write your own forms or links
> that could generate validation errors, you must include a value for this
> parameter. This can be done by calling request.getServletPath()."
>
>
> Any ideas how to get this working?
>
>
>
>
>
> ------------------------------------------------------------------------------
> Minimize network downtime and maximize team effectiveness.
> Reduce network management and security costs.Learn how to hire
> the most talented Cisco Certified professionals. Visit the
> Employer Resources Portal
> http://www.cisco.com/web/learning/employer_resources/index.html
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

VANKEISBELCK Remi
Bug filed :
http://www.stripesframework.org/jira/browse/STS-900

Thanks for your feedback.

Cheers

Remi

Le 4 avr. 2013 à 17:08, Remi VANKEISBELCK a écrit :

> Just tried it out of curiosity and reproduced the problem.
>
> The issue disappears if you have a real JSP to forward to and everything works as expected.
>
> Then if you have a fictious JSP with path starting by "/" you have another error (a 404, which is expected). But you have the same "source page not found" error if the path doesn't start by "/".
>
> Definitely looks like a bug : you should have a 404 instead of a validation error.  
>
> Mikko, you can workaround by forwarding to an actual JSP page (we usually toss them under WEB-INF in order to make them available only using intenal forwards via ForwardResolution : we usually only expose ActoinBeans, not JSPs). You don't need to tell Stripes which converter to use, int is built-in.
>
> I'm gonna file a bug and test case. Thanks for the report.
>
> Cheers
>
> Remi
>
>
> Le 4 avr. 2013 à 13:10, Mikko Saarela a écrit :
>
>> Hi,
>>
>> I'm getting a Stripes validation error report after going to URL:
>>
>> http://www.myserver.com/my-app/some/1
>>
>> "The value (1) entered in field My Value must be a valid number"
>>
>> I have clean URLs configured.
>>
>> My ActionBean is like this:
>>
>> @UrlBinding("/some/{myValue}")
>> public class SomeActionBean implements ActionBean {
>>   private ActionBeanContext context;
>>
>>   @Validate(converter=IntegerTypeConverter.class)
>>   private int myValue;
>>
>>   @DefaultHandler
>>   public Resolution view() {
>>
>>       System.out.println(myValue);
>>       return new ForwardResolution("some.jsp");
>>   }
>>
>>   @Override
>>   public ActionBeanContext getContext() {
>>       return context;
>>   }
>>
>>   @Override
>>   public void setContext(ActionBeanContext context) {
>>       this.context = context;
>>   }
>>
>>   public int getMyValue() {
>>       return myValue;
>>   }
>>
>>   public void setMyValue(int myValue) {
>>       this.myValue = myValue;
>>   }
>> }
>>
>> The full error message was:
>> "Here's how it is. Someone (quite possibly the Stripes Dispatcher) needed to
>> get the source page resolution. But no source page was supplied in the
>> request, and unless you override ActionBeanContext.getSourcePageResolution()
>> you're going to need that value. When you use a <stripes:form> tag a hidden
>> field called '_sourcePage' is included. If you write your own forms or links
>> that could generate validation errors, you must include a value for this
>> parameter. This can be done by calling request.getServletPath()."
>>
>>
>> Any ideas how to get this working?
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Minimize network downtime and maximize team effectiveness.
>> Reduce network management and security costs.Learn how to hire
>> the most talented Cisco Certified professionals. Visit the
>> Employer Resources Portal
>> http://www.cisco.com/web/learning/employer_resources/index.html
>> _______________________________________________
>> Stripes-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

Mikko Saarela
In reply to this post by VANKEISBELCK Remi
> Just tried it out of curiosity and reproduced the problem.
>
> The issue disappears if you have a real JSP to forward to and everything
works as expected.

I have a real JSP page that I'm forwarding to, but it gives that error
regardless.

The example I posted was real code, even though it was a simplified from the
actual application code with which I ran into this problem.

Thank you for your help Remi :)


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Clean URL Parameters

VANKEISBELCK Remi
You don't have no leading "/" in the path to your JSP :

> return new ForwardResolution("some.jsp");

Your path *must* start by "/" otherwise you have this weird error.

Cheers

Remi


Le 5 avr. 2013 à 08:20, Mikko Saarela a écrit :

>> Just tried it out of curiosity and reproduced the problem.
>>
>> The issue disappears if you have a real JSP to forward to and everything
> works as expected.
>
> I have a real JSP page that I'm forwarding to, but it gives that error
> regardless.
>
> The example I posted was real code, even though it was a simplified from the
> actual application code with which I ran into this problem.
>
> Thank you for your help Remi :)
>
>
> ------------------------------------------------------------------------------
> Minimize network downtime and maximize team effectiveness.
> Reduce network management and security costs.Learn how to hire
> the most talented Cisco Certified professionals. Visit the
> Employer Resources Portal
> http://www.cisco.com/web/learning/employer_resources/index.html
> _______________________________________________
> Stripes-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users