You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pavel Sapozhnikov <pa...@gmail.com> on 2007/11/19 22:48:50 UTC

opening a new window if validated

Hi I have a question. I am not sure if this is a Struts question or an HTML
question so here we go. I have a form on page x I submit the form validation
failed it goes back to the page x which is fine but then if validated true
it should open a new window with the stuff that should be there. So again I
am not sure if this is Struts question or HTML question I tried doing
onsubmit="validateSomething()" and then that would do javascript validation
but then it didn't display my html:errors. So any help would be really
appreciated. Thanks.


-- 
Pavel Sapozhnikov
xFact, Inc
pavel@xfact.com

Re: opening a new window if validated

Posted by Pavel Sapozhnikov <pa...@gmail.com>.
Hey Adam thanks. So basically one of the things I did was when I am on page
x I validate using client side JS validation either written myself or
html:javascript doesn't really metter but both of those two methods pop up
an alert and doesn't actually put it right in the page like html:errors
does. But then yeah it actually works I still have target there and it opens
a new window only when validation succeded thats fine is there any way to
make javascript display html:errors like right in page and not in a pop up I
looked at html:errors it doesn't have an id or styleId attribute which means
I can't do my document.getElementByID('id').innerHTML = 'some error'. So
what do you recommend. By the way thanks for your input.

Pavel

On Nov 19, 2007 5:38 PM, Adam Gordon <ad...@readytalk.com> wrote:

> It could actually be both.  I assume you are using both client and
> server side JavaScript validation (at the very least you should be doing
> server side since HTML pages can be manipulated).
>
> So, assuming you are doing both, you need the page you submitted the
> data on to go somewhere because you want to chain the action, i.e., you
> want to have another window open.  One way to do this is to have the
> main page come back and set a request attribute that indicates you are
> to open the pop-up window.  In J/S land in your JSP (inside a <script>
> element at the bottom of the page you can have code that checks for this
> parameter (using '${paramName}') and if it's present open the pop-up
> window.
>
> Word to the wise...if your popup window relies on elements existing in
> the page (and it doesn't sound like it does) then you need to use some
> sort of window.onload function (or replace window.onload with some type
> of callback chain mechanism - I can provide you w/ a link to the one we
> use) so that you can be sure that the page is fully loaded/rendered
> before the script executes.
>
> Hope that helps.
>
> --adam
> -----Original Message-----
> From: Pavel Sapozhnikov [mailto:pavel.sapozhnikov@gmail.com]
> Sent: Monday, November 19, 2007 2:49 PM
> To: Struts Users Mailing List
> Subject: opening a new window if validated
>
> Hi I have a question. I am not sure if this is a Struts question or an
> HTML
> question so here we go. I have a form on page x I submit the form
> validation
> failed it goes back to the page x which is fine but then if validated
> true
> it should open a new window with the stuff that should be there. So
> again I
> am not sure if this is Struts question or HTML question I tried doing
> onsubmit="validateSomething()" and then that would do javascript
> validation
> but then it didn't display my html:errors. So any help would be really
> appreciated. Thanks.
>
>
> --
> Pavel Sapozhnikov
> xFact, Inc
> pavel@xfact.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Pavel Sapozhnikov
xFact, Inc
pavel@xfact.com

RE: opening a new window if validated

Posted by Adam Gordon <ad...@readytalk.com>.
It could actually be both.  I assume you are using both client and
server side JavaScript validation (at the very least you should be doing
server side since HTML pages can be manipulated).

So, assuming you are doing both, you need the page you submitted the
data on to go somewhere because you want to chain the action, i.e., you
want to have another window open.  One way to do this is to have the
main page come back and set a request attribute that indicates you are
to open the pop-up window.  In J/S land in your JSP (inside a <script>
element at the bottom of the page you can have code that checks for this
parameter (using '${paramName}') and if it's present open the pop-up
window.

Word to the wise...if your popup window relies on elements existing in
the page (and it doesn't sound like it does) then you need to use some
sort of window.onload function (or replace window.onload with some type
of callback chain mechanism - I can provide you w/ a link to the one we
use) so that you can be sure that the page is fully loaded/rendered
before the script executes.

Hope that helps.

--adam
-----Original Message-----
From: Pavel Sapozhnikov [mailto:pavel.sapozhnikov@gmail.com] 
Sent: Monday, November 19, 2007 2:49 PM
To: Struts Users Mailing List
Subject: opening a new window if validated

Hi I have a question. I am not sure if this is a Struts question or an
HTML
question so here we go. I have a form on page x I submit the form
validation
failed it goes back to the page x which is fine but then if validated
true
it should open a new window with the stuff that should be there. So
again I
am not sure if this is Struts question or HTML question I tried doing
onsubmit="validateSomething()" and then that would do javascript
validation
but then it didn't display my html:errors. So any help would be really
appreciated. Thanks.


-- 
Pavel Sapozhnikov
xFact, Inc
pavel@xfact.com

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