You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rich M <ri...@moremagic.com> on 2010/10/25 19:29:52 UTC

Form submit conditionally opening new window

Hi,

a while back I built in JasperReports support into my application, and 
on the pages accessing this I had a form with target="_blank" to open 
the reports in a new window. I'm now being required to enforce a 
restriction on some parameters feeding into the reports, and I want to 
do this on the server side with onValidateFromXX method(s). The issue 
I'm having is that using the target="_blank" in the template means that 
in the event of an error in the form fields, a new window opens 
displaying the form with errors, but the original screen is left 
untouched. The validation works, but this certainly is not going to be 
acceptable application behavior.

Is there a way to get the browser to open a new window from within 
Tapestry, maybe in a StreamResponse (since that I what I'm using to 
render the reports)?

Thanks,
Rich

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


Re: Form submit conditionally opening new window

Posted by Rich M <ri...@moremagic.com>.
Whoops, just a quick comment, the DateFields are the Tapestry Core 
components, not the ChenilleKit DateTimeFields, forgot to edit that 
after double checking.-Rich

On 10/27/2010 04:59 PM, Rich M wrote:
> Ah okay. I'm trying to decide where is best to hook up some AJAX 
> request to achieve this. The fields I need to validate are two 
> DateFields (I believe the ChenilleKit components). I'm finding it 
> hard, however to find the proper Prototype DOM event to bind the 
> listener to.
>
> I tried change, but this one does not seem to fire on these 
> components. Meanwhile, blur occurs as you make a selection in the 
> Calendar, that is you focus when you pop-up the calendar, then blur 
> when you make a selection, and then focus again after you confirm the 
> selection. So unfortunately, it seems like blur happens right before I 
> could capture the new setting and validate it.
>
> I looked at the source for DateField, but I didn't see anything that 
> popped out at me.
>
> The only other solution that occurred to me would be to somehow fire 
> AJAX validation on the submit button, but there aren't many DOM events 
> that will be able to fire the AJAX whilst not eventually submitting 
> the form. As far as I'm aware, if I did click,mousedown, or mouseup, 
> at some point before/during/after the AJAX the form will be submitted 
> anyway and the new window will come up for the user. I could do 
> mouseover, but that seems like a real hack not to mention something 
> that would probably surprise the user.
>
> Any suggestions?
>
> Thanks,
> Rich
>
> On 10/25/2010 01:35 PM, Thiago H. de Paula Figueiredo wrote:
>> On Mon, 25 Oct 2010 15:29:52 -0200, Rich M <ri...@moremagic.com> 
>> wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>> Is there a way to get the browser to open a new window from within 
>>> Tapestry, maybe in a StreamResponse (since that I what I'm using to 
>>> render the reports)?
>>
>> AFAIK, no, as this is a purely client behavior. You'll need to solve 
>> this with a AJAX request just to validate the form before you do an 
>> actual form submission.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Form submit conditionally opening new window

Posted by Rich M <ri...@moremagic.com>.
Ah okay. I'm trying to decide where is best to hook up some AJAX request 
to achieve this. The fields I need to validate are two DateFields (I 
believe the ChenilleKit components). I'm finding it hard, however to 
find the proper Prototype DOM event to bind the listener to.

I tried change, but this one does not seem to fire on these components. 
Meanwhile, blur occurs as you make a selection in the Calendar, that is 
you focus when you pop-up the calendar, then blur when you make a 
selection, and then focus again after you confirm the selection. So 
unfortunately, it seems like blur happens right before I could capture 
the new setting and validate it.

I looked at the source for DateField, but I didn't see anything that 
popped out at me.

The only other solution that occurred to me would be to somehow fire 
AJAX validation on the submit button, but there aren't many DOM events 
that will be able to fire the AJAX whilst not eventually submitting the 
form. As far as I'm aware, if I did click,mousedown, or mouseup, at some 
point before/during/after the AJAX the form will be submitted anyway and 
the new window will come up for the user. I could do mouseover, but that 
seems like a real hack not to mention something that would probably 
surprise the user.

Any suggestions?

Thanks,
Rich

On 10/25/2010 01:35 PM, Thiago H. de Paula Figueiredo wrote:
> On Mon, 25 Oct 2010 15:29:52 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> Hi,
>
> Hi!
>
>> Is there a way to get the browser to open a new window from within 
>> Tapestry, maybe in a StreamResponse (since that I what I'm using to 
>> render the reports)?
>
> AFAIK, no, as this is a purely client behavior. You'll need to solve 
> this with a AJAX request just to validate the form before you do an 
> actual form submission.
>


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


Re: Form submit conditionally opening new window

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 25 Oct 2010 15:29:52 -0200, Rich M <ri...@moremagic.com> wrote:

> Hi,

Hi!

> Is there a way to get the browser to open a new window from within  
> Tapestry, maybe in a StreamResponse (since that I what I'm using to  
> render the reports)?

AFAIK, no, as this is a purely client behavior. You'll need to solve this  
with a AJAX request just to validate the form before you do an actual form  
submission.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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