You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by James <ja...@mweb.co.za> on 2005/11/20 09:00:09 UTC

JavaScript in forms with Tapestry

Hi

I posted this on tapestryforums.com yesterday, but it seems I might have
more luck here, and I'm not ready to give up on Tapestry just yet:

I've spent the last few days trying to get to grips with Tapestry with a
view to using it for a project I need to develop within the next month
or so. I think I'm pretty familiar with the basics of the framework now,
but I've hit a snag. My application needs to use client-side javascript
to add extra input fields to a form - fields that were not there when
the form was originally sent to the client. It is not desirable for the
client to click a button and have the server send back a form with the
new field added. 

Because of the way Tapestry deals with forms, it looks like this is
going to be difficult for me. Is it possible for me to achieve what I
need to in Tapestry, either by 'standard' means, or by intercepting the
form on a lower level? If I plan to use this technique often in my
application, is it even worth using Tapestry, or should I opt for a
framework that deals more explicitly with requests, responses, posts,
etc.?


James


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: JavaScript in forms with Tapestry

Posted by Jesse Kuhnert <jk...@gmail.com>.
Hi James,

I wouldn't give up on tapestry just yet ;) What you want to do is
specifically being handled already if you go to
http://tacos.sourceforge.net.

The good news is that adding new input fields to a form is really
quite easily with tacos, and your users won't have the added annoyance
of having the page refreshed when you add these fields in.

The bad news is that this particular type of support isn't available
in the current offical release(alpha-6), so you'd have to checkout
tacos from cvs. Building is easy luckily via "ant build-lib".

I'm not sure which approach you are wanting to take with the form in
question, but if you give me more details about the specific
interactions of what you are trying to do with these fields I could
probably give you some guidance.

All I can say is that your particular needs are being directly
addressed in a pretty easy way, so if you have time to play go
checkout tacos. (If you do check out the project from cvs I would
reccomend running the latest demo war, buildable via ant build-war and
check out the Dialog component demo page..It has some very impressive
features that I think might provide an even better way to deal with
your dynamic inputs than you originally thought. More about this
technique is discussed in a recent article here:
http://ajaxian.com/archives/2005/11/ajax_dialog_win.html ).

jesse

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: JavaScript in forms with Tapestry

Posted by Jesse Kuhnert <jk...@gmail.com>.
Just in case you caught cvs at a bad time, I was/did re-factor a few
things today that would've affected Dialog. The changes have been
completed now, in case you were noticing anything...


On 11/20/05, James <ja...@mweb.co.za> wrote:
> Perhaps I expressed myself incorrectly with regard to 'rebuilding the
> form'. The rebuilding of the form was not so much a concern as was
> sending it back to the client. The nature of the data entry that needs
> to be done (and its sheer volume) requires that the user be able to
> continue absolutely uninterrupted for whatever period of time he
> chooses.
>
> A large proportion of the users will probably be accessing the page with
> dial-up accounts, running through antiquated South African telephone
> exchanges. A delay of even a few seconds per entry would be untenable,
> and such a delay would doubtless occur were I to adopt the usual
> Tapestry approach.
>
> Your second idea, however, sounds fantastic and I think I'll try that
> right now.
>
>
> James
>
> -----Original Message-----
> From: Richard Clark [mailto:rdclark@nextquestion.net]
> Sent: 20 November 2005 11:19 PM
> To: Tapestry users
> Subject: Re: JavaScript in forms with Tapestry
>
> You may want to try a small prototype using the usual Tapestry
> approach and user-test it. Tapestry caches page layouts in normal
> operation, so the submit-render cycle is very fast.  "Waiting for the
> server to rebuild the form" may well take less time than you think.
>
> Then, if you find you still need to do this in JavaScript, you could
> have 2 forms -- the one that Tapestry sees (with a couple of hidden
> fields) and a dynamic form built by JavaScript. When the user hits
> submit, run a locak piece of JavaScript to package the data up
> yourself and shove it into the hidden field, then submit the static
> form to Tapestry. Take that block of data, unpack it yourself on the
> server (pretty simple to do in Java) and take it from there.
>
>   ...Richard
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: JavaScript in forms with Tapestry

Posted by James <ja...@mweb.co.za>.
Perhaps I expressed myself incorrectly with regard to 'rebuilding the
form'. The rebuilding of the form was not so much a concern as was
sending it back to the client. The nature of the data entry that needs
to be done (and its sheer volume) requires that the user be able to
continue absolutely uninterrupted for whatever period of time he
chooses.

A large proportion of the users will probably be accessing the page with
dial-up accounts, running through antiquated South African telephone
exchanges. A delay of even a few seconds per entry would be untenable,
and such a delay would doubtless occur were I to adopt the usual
Tapestry approach.

Your second idea, however, sounds fantastic and I think I'll try that
right now.


James

-----Original Message-----
From: Richard Clark [mailto:rdclark@nextquestion.net] 
Sent: 20 November 2005 11:19 PM
To: Tapestry users
Subject: Re: JavaScript in forms with Tapestry

You may want to try a small prototype using the usual Tapestry  
approach and user-test it. Tapestry caches page layouts in normal  
operation, so the submit-render cycle is very fast.  "Waiting for the  
server to rebuild the form" may well take less time than you think.

Then, if you find you still need to do this in JavaScript, you could  
have 2 forms -- the one that Tapestry sees (with a couple of hidden  
fields) and a dynamic form built by JavaScript. When the user hits  
submit, run a locak piece of JavaScript to package the data up  
yourself and shove it into the hidden field, then submit the static  
form to Tapestry. Take that block of data, unpack it yourself on the  
server (pretty simple to do in Java) and take it from there.

  ...Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: JavaScript in forms with Tapestry

Posted by Richard Clark <rd...@nextquestion.net>.
You may want to try a small prototype using the usual Tapestry  
approach and user-test it. Tapestry caches page layouts in normal  
operation, so the submit-render cycle is very fast.  "Waiting for the  
server to rebuild the form" may well take less time than you think.

Then, if you find you still need to do this in JavaScript, you could  
have 2 forms -- the one that Tapestry sees (with a couple of hidden  
fields) and a dynamic form built by JavaScript. When the user hits  
submit, run a locak piece of JavaScript to package the data up  
yourself and shove it into the hidden field, then submit the static  
form to Tapestry. Take that block of data, unpack it yourself on the  
server (pretty simple to do in Java) and take it from there.

  ...Richard



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: JavaScript in forms with Tapestry

Posted by James <ja...@mweb.co.za>.
Thanks for the advice. I was afraid this might be the case. While I'm
quite comfortable now with putting together a relatively simple Tapestry
application, I don't know that I'm quite ready to start delving into the
guts of it - especially with a fairly limited timeframe.

I see your point on manipulating forms client-side with JavaScript, but
the nature of the application I need to build is such that the users are
entering large amounts of data under some considerable duress and
therefore we can't reasonably have them wait for the server to rebuild
the form before they enter more data, or - worse - have them submit a
new form for each entry they make.

I was looking for an excuse to build something in Tapestry - but it
looks like this just isn't it.


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: JavaScript in forms with Tapestry

Posted by Ron Piterman <rp...@gmx.net>.
just another thing...
fields added by javascript could be validated in the client-side 
validation of  tapestry. But should be excluded from the server side 
cycle (rewind).
Ron


James wrote:
> Hi
> 
> I posted this on tapestryforums.com yesterday, but it seems I might have
> more luck here, and I'm not ready to give up on Tapestry just yet:
> 
> I've spent the last few days trying to get to grips with Tapestry with a
> view to using it for a project I need to develop within the next month
> or so. I think I'm pretty familiar with the basics of the framework now,
> but I've hit a snag. My application needs to use client-side javascript
> to add extra input fields to a form - fields that were not there when
> the form was originally sent to the client. It is not desirable for the
> client to click a button and have the server send back a form with the
> new field added. 
> 
> Because of the way Tapestry deals with forms, it looks like this is
> going to be difficult for me. Is it possible for me to achieve what I
> need to in Tapestry, either by 'standard' means, or by intercepting the
> form on a lower level? If I plan to use this technique often in my
> application, is it even worth using Tapestry, or should I opt for a
> framework that deals more explicitly with requests, responses, posts,
> etc.?
> 
> 
> James
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: JavaScript in forms with Tapestry

Posted by Ron Piterman <rp...@gmx.net>.
As far as I can see if you want to use the very good validation and 
comfortable form handling in tapestry you should render all of your 
fields with the page. You could make some of the hidden by css and 
change that through javascript, but at the moment you should not add 
fields from java script.
You could do it if you create a custom, non-form component, which takes 
the values of the generated fields and processes them by it self. This 
will lead to taking these values out of the validation cycle, and is, to 
my opinion, not a good practice. not when using tapestry.
Cheers,
Ron


James wrote:
> Hi
> 
> I posted this on tapestryforums.com yesterday, but it seems I might have
> more luck here, and I'm not ready to give up on Tapestry just yet:
> 
> I've spent the last few days trying to get to grips with Tapestry with a
> view to using it for a project I need to develop within the next month
> or so. I think I'm pretty familiar with the basics of the framework now,
> but I've hit a snag. My application needs to use client-side javascript
> to add extra input fields to a form - fields that were not there when
> the form was originally sent to the client. It is not desirable for the
> client to click a button and have the server send back a form with the
> new field added. 
> 
> Because of the way Tapestry deals with forms, it looks like this is
> going to be difficult for me. Is it possible for me to achieve what I
> need to in Tapestry, either by 'standard' means, or by intercepting the
> form on a lower level? If I plan to use this technique often in my
> application, is it even worth using Tapestry, or should I opt for a
> framework that deals more explicitly with requests, responses, posts,
> etc.?
> 
> 
> James
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org