|
Saul,
onsubmit() isn't a _javascript_ method so it wouldn't be generated by
JSF. It is a form object method internal to the browser. I don't
know offhand the technical term but it is probably part of the DOM (Document
Object Model).
Regards,
David
Matt,
Based on your onsubmit suggestion, I changed my
code to submit the form from:
document.forms['body:theForm'].submit();
to
if(document.forms['body:theForm'].onsubmit)
{ if(document.forms['body:theForm'].onsubmit())
document.forms['body:theForm'].submit(); }
else
{ document.forms['body:theForm'].submit(); }
Now it works! the parent page refreshes with the
populated value retained.
One strange thing though, I don't see
JSF rendering a onsubmit() function inside the form tag. Anyway, it's
working.
thanks a lot for the help, Matt &
whoever responed to the question
Saul.
----- Original Message -----
Sent: Tuesday, September 27, 2005 12:46
PM
Subject: Re: Using _javascript_ to submit
a form doesn't work
You can see for yourself what the _javascript_ code that's
being generated is, just by running the page and using your browser's View
Source functionality.
If there's an onsubmit handler, the code you
list will do exactly what needs to be done. It's possible, though,
that there's an onchange handler on the input box (say, that populates a
hidden field) that may not be called when the value changes
programmatically.
-Matt
On 9/27/05, Saul
Qunming Yuan <[EMAIL PROTECTED]> wrote:
Yes,
I do have two commandButton there in the parent window. I just populate
one id value to the parent window and I see it showing up in the input
box before the parent window refreshes. Once the parent
window refreshes though, it clears out the value populated in the input
box. I'm sure JSF generate a bunch of _javascript_ code, may be I need
to call the onsubmit before calling submit, something like
this:
parentWinForm.onsubmit(); parentWinForm.submit();
thanks.
>
(accidentally just replied to the sender, so re-sending to the discussion
> group) > > Does the form in the parent window have a
submit button? Zhong Li was > right > that you may need at
least one submit button in order for it to work > (there's no
logical reason why you should, but sometimes the browser gets >
testy if you don't). > > If you don't have an onsubmit handler
already, you don't need to create > one. > I just thought you
might've had one that, due to the way you were > submitting >
the form, was not being called. > > Are you sure the search
got populated everywhere it needed to be? Is there > any _javascript_
behind the scenes that isn't being invoked due to the fact > that
you're populating the search field via code instead of by typing in
> it? > If you're not sure, look at the rendered HTML source
for the page, and > check > for hidden fields and _javascript_
code that you didn't write (i.e., that > must've been rendered by
MyFaces). > > -Matt > > On 9/27/05, Saul Qunming
Yuan <[EMAIL PROTECTED]>
wrote: >> >> Thanks Matt, that's a very good point. But
what do I need to do in the >> Onsubmit handler? I have already
set the values to the input fields >> using >>
_javascript_. >> >> Just to be clear, here is my use
case: >> >> 1. The parent window has a "Search" button;
>> 2. When the "Search" button is clicked, it opens a popup
window; >> 3. The user does the search in the popup window, find
a list of results; >> 4. The user clicks a link from the search
result which calls a >> _javascript_ >> function to
populate some value to the parent window; >> 5. The _javascript_
function then calls the parent window's form object to >> submit
(like parentWinForm.submit()) the parent form; >> 6. Close the
Popup window. >> >> The issue
is: >> >> The search did got populated in the parent
window, and the parent window >> did refresh, but the parent
window didn't do a post using the populated >> value from the
search. The backing bean's setter methods not
called. >> >> >> >> >> >
Does the form have an onsubmit handler that needs to be called to
set >> any >> > of >> > its values?
Onsubmit handlers aren't called when you invoke the submit >>
> method on the form object, so you will need to call whatever
function >> it >> > is >> > explicitly
before the invocation. >> > >> > If that's not
what it is, then I don't know what to suggest. >>
> >> > -Matt >> > >> > On 9/26/05,
Saul Qunming Yuan < [EMAIL PROTECTED]>
wrote: >> >> >> >> Hi all, >>
>> I'm trying to use _javascript_ to submit a form, the page does
refresh, >> >> however, it doesn't appear to be a post
action, the form inputs don't >> >> update >>
>> the value in the backing bean, none of the setter methods get
called. >> >> It's >> >> like a get action.
Any ideas what the problem could be? >> >>
thanks, >> >> Saul >> >> >>
> >> >> >> >
|