T5: how to circumvent t:formdata

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

T5: how to circumvent t:formdata

Michael Capper
Hi,
I've got a form which i'd like to submit direcly in a mobile application without prior loading of the page. I then wouldn't have a correct value for a t:formata hidden field, which seems required and also seems to change every now and then. I understand this is for some security reason, but can this t:formdata-parameter somehow be omitted, or set to a fixed value?

Thanks,
Michael
Reply | Threaded
Open this post in threaded view
|

Re: T5: how to circumvent t:formdata

Massimo Lusetti
On Mon, Jan 26, 2009 at 5:49 PM, Michael Capper <[hidden email]> wrote:

> Hi,
> I've got a form which i'd like to submit direcly in a mobile application
> without prior loading of the page. I then wouldn't have a correct value for
> a t:formata hidden field, which seems required and also seems to change
> every now and then. I understand this is for some security reason, but can
> this t:formdata-parameter somehow be omitted, or set to a fixed value?

Short answer: No
Long answed: It shouldn't change from version to version so it is
fixed and you can hardcode it but afaik T5 need it to process the form
submission.

I too have great interest in having another way to submit form to T5
page from an automated-station and would like to here from Howard
which is his feeling and how we can help if that's the case.

Regards
--
Massimo
http://meridio.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: how to circumvent t:formdata

Howard Lewis Ship
If you use a Form component, you need the t:formdata.

If you don't use Form (and therefore, don't use TextField, Select,
etc.) you can easily submit directly into a component event handler
method; it's a step back towards servlet-style coding, where you
inject the Request and pull parameters out to do with as you please.


On Mon, Jan 26, 2009 at 9:17 AM, Massimo Lusetti <[hidden email]> wrote:

> On Mon, Jan 26, 2009 at 5:49 PM, Michael Capper <[hidden email]> wrote:
>
>> Hi,
>> I've got a form which i'd like to submit direcly in a mobile application
>> without prior loading of the page. I then wouldn't have a correct value for
>> a t:formata hidden field, which seems required and also seems to change
>> every now and then. I understand this is for some security reason, but can
>> this t:formdata-parameter somehow be omitted, or set to a fixed value?
>
> Short answer: No
> Long answed: It shouldn't change from version to version so it is
> fixed and you can hardcode it but afaik T5 need it to process the form
> submission.
>
> I too have great interest in having another way to submit form to T5
> page from an automated-station and would like to here from Howard
> which is his feeling and how we can help if that's the case.
>
> Regards
> --
> Massimo
> http://meridio.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: T5: how to circumvent t:formdata

Michael Capper
Thank you, it works now
For reference, my Input class now includes:

        @Inject
        private RequestGlobals requestGlobals;

        @OnEvent(value = "onMobileSubmit")
        public StreamResponse onMobileSubmit()
        {
                HttpServletRequest request = requestGlobals.getHTTPServletRequest();
                this.username = request.getParameter("username");
                this.password = request.getParameter("password");
                //etc... manually reading out the parameters the "normal" form on this page would have set
                String result = "";
                try
                {
                        onValidateForm();
                        onSuccess();
                        result = "OK";
                }
                catch (ValidationException v)
                {
                        onFailure();
                        result = v.getMessage();
                }
                final String answer = result;
                return new StreamResponse()
                {
                        public String getContentType()
                        {
                                return "text/html";
                        }
                        public InputStream getStream() throws IOException
                        {
                                return new ByteArrayInputStream(answer.getBytes());
                        }
                        public void prepareResponse(Response arg0)
                        {
                        }
                };
        }

which i can call directly as localhost:8080/xxx/input:onMobileSubmit from my mobile app while posting the parameters.

Howard Lewis Ship wrote
If you use a Form component, you need the t:formdata.

If you don't use Form (and therefore, don't use TextField, Select,
etc.) you can easily submit directly into a component event handler
method; it's a step back towards servlet-style coding, where you
inject the Request and pull parameters out to do with as you please.
Reply | Threaded
Open this post in threaded view
|

Re: T5: how to circumvent t:formdata

Massimo Lusetti
In reply to this post by Howard Lewis Ship
On Mon, Jan 26, 2009 at 7:39 PM, Howard Lewis Ship <[hidden email]> wrote:

> If you use a Form component, you need the t:formdata.
>
> If you don't use Form (and therefore, don't use TextField, Select,
> etc.) you can easily submit directly into a component event handler
> method; it's a step back towards servlet-style coding, where you
> inject the Request and pull parameters out to do with as you please.

It isn't better to (hard)code the t:formdata parameter value in the
application which submits the form and take advantage of all the T5
features, from life cycle methods to validation to type coercion and
so on?

Hardcoding any value is almost always a bad practice but in this case
it seems to me it has more advantages then drawbacks.

--
Massimo
http://meridio.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]