Ok, so what does clear...Form(); do?

Imagine you click on a link in JSF - what happens is that a hidden
field is set, one for the link itself, and one for every parameter of
the link.

If you cancel the loading of the next page, these parameters are still set.

Now if you click on another link, you still have the old parameters
set, along with the new parameters for the new link, that makes
already two links which will fire action events.

This is where the clear...Form(); method comes in handy; it cleans out
all these parameters, and the problem is solved.

regards,

Martin



On 9/19/06, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
Unfortunatley, I don't know the answer to those questions.

It's also possible that what I had no longer works with later versions
of MyFaces.  I know that some effort was recently put in to make the
clear functions compatible with JSF RI in the latest MyFaces
snapshots.  It's probable that this should make life easier -- I'm
guessing both JSF implementations now have matching javascript names.

On 9/19/06, Jeff Bischoff <[EMAIL PROTECTED]> wrote:
> I wouldn't mind at all, but first I would like to understand the code a
> little better. In particular, this line in my javascript:
>
> clear_MainForm();
>
> It calls the javascript function generated by MyFaces. I copied it from
> your code, and I think you included it to emulate the behaviour of
> commandButtons? But what exactly does this function call accomplish? I
> see that it resets the hidden field and the datatable (if present)
> scroll. Will I want to keep this line as part of my documented solution,
> or make it an additional optional step they can take, that is unrelated
> to the scrolling issue?
>
> Regards,
>
> Jeff Bischoff
> Kenneth L Kurz & Associates, Inc.
>
> Mike Kienenberger wrote:
> > On 9/15/06, Jeff Bischoff <[EMAIL PROTECTED]> wrote:
> >> (A response to the message by Mike Kienenberger  2005-11-07 16:56)
> >>
> >> Have you had any luck with your scrolling ideas, in the time since this
> >> thread? I'm sure that by now you must have figured something out to
> >> accomplish what you were trying to do.
> >
> > You'd like to think that, but in fact, I never made any progress.
> > The project I was going to use it on was postponed.
> >
> >
> >> In any case, I made a simple javascript function based off what you
> >> provided in this thread. It's working great for my needs! Thanks for
> >> your ideas, which helped me get started.
> >
> > Great!  Do you mind documenting it on a MyFaces wiki page somewhere?
> > Perhaps we can figure out a more generic way to do this down the road
> > -- maybe a scrollTo component tag.
> >
> >
> >> The archive for this mailing list really is priceless.
> >>
> >> <script language="javascript">
> >>    function setScrollingAndSubmit(){
> >>      clear_MainForm();
> >>
> >> document.forms['MainForm'].elements['autoScroll'].value=getScrolling();
> >>      document.forms['MainForm'].submit();
> >> }
> >> </script>
> >>
> >> My form is named "MainForm", and never changes so its hardcoding is not
> >> a problem for me.
> >>
> >> Regards,
> >>
> >> Jeff Bischoff
> >> Kenneth L Kurz & Associates, Inc.
> >>
> >> On 11/07/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> >>  >Stefan,
> >>  >
> >>  >Did you make any progress on this?
> >>  >
> >>  >I was looking at it again today, and it seemed to me that I could use
> >>  >the following code to accomplish this kind of effect. My thinking was
> >>  >that calling getScrolling() from the onchange of the <select> would
> >>  >use the coordinates of the <select> element instead of the submitting
> >>  >button.
> >>  >
> >>  >Unfortunately, it doesn't seem to work.
> >>  >
> >>  >=================================================
> >>  >
> >>  >    <h:selectOneMenu
> >>  >        onchange="pulldownChanged()"
> >>  >        value="#{dataModel.itemValue}">
> >>  >        <f:selectItems value="#{page.items}"/>
> >>  >    </h:selectOneMenu>
> >>  >
> >>  >    <script language="javascript">
> >>  >    // <![CDATA[
> >>  >    function pulldownChanged(){
> >>  >        clear_form();
> >>  >
> >>  >document.forms['form'].elements['autoScroll'].value=getScrolling();
> >>  >
> >> >document.getElementById("form:nonclearingRefreshButton").click();
> >>  >    }
> >>  >    // ]]>
> >>  >    </script>
> >>  >
> >>  >    <!-- non-clearing refresh button; JSF will see it as
> >> refreshButton -->
> >>  >    <f:verbatim>
> >>  >        <input type="submit" style="display: none;" value="Submit"
> >> name="form:refreshButton" id="form:nonclearingRefreshButton"/>
> >>  >    </f:verbatim>
> >>  >
> >>  >    <!-- never used directly; refreshButton exists so verbatim html
> >> above can imitate it -->
> >>  >    <h:commandButton id="refreshButton"
> >>  >        value="Submit" action="#{page.refresh}"
> >>  >        style="display:none">
> >>  >    </h:commandButton>
> >>  >
> >> On 10/27/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> >>  > Stefan,
> >>  >
> >>  > You are correct in that the current implementation only scrolls to a
> >>  > link or a button.   I was proposing that you take advantage of the
> >>  > infrastructure that was there to expand to to scroll to other
> >>  > components.
> >>  >
> >>  > I'm not sure exactly how it would work, but I'd think in the short
> >>  > term, it would be something like this.
> >>  >
> >>  >     onclick="setScrollToComponentAndSubmit()"
> >>  >
> >>  > You may have to manually create a button to submit it.  This is a
> >>  > similar button I use to trigger special javascript submit code.
> >>  >
> >>  >     <f:verbatim>
> >>  >         <input type="submit" style="display: none;"
> >>  >
> >> 
onclick="document.forms['form'].elements['autoScroll'].value=getScrolling();"
> >>
> >>  > value="Submit" name="form:refreshButton"
> >>  > id="form:nonclearingRefreshButton"/>
> >>  >     </f:verbatim>
> >>  >
> >>  > If you're looking to contribute a myfaces component to handle all of
> >>  > this automatically, I can only point you in the right direction (the
> >>  > autoScroll field and the getScrolling() function).   You'll have to
> >>  > figure out the details as I don't have the skillset (javascript) to
> >>  > help you.  :)
> >>  > But there's already something in place in MyFaces.  It's just a matter
> >>  > of converting it to your needs.
> >>  >
> >>  > On 10/27/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >>  > >
> >>  > > Mike
> >>  > >
> >>  > > <context-param>
> >>  > >         <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
> >>  > >         <param-value>true</param-value>
> >>  > >         <description>
> >>  > >             If true, a javascript function will be rendered that is
> >>  > > able to restore the
> >>  > >             former vertical scroll on every request. Convenient
> >>  > > feature if you have pages
> >>  > >             with long lists and you do not want the browser page to
> >>  > > always jump to the top
> >>  > >             if you trigger a link or button action that stays on
> >> the same
> >>  > > page.
> >>  > >             Default: "false"
> >>  > >         </description>
> >>  > >
> >>  > >
> >>  > >     </context-param>
> >>  > >
> >>  > >
> >>  > >
> >>  > > Have already got that set in my web.xml
> >>  > >
> >>  > > Guess it's not operating because I'm NOT using a link or button
> >> action – see
> >>  > > jsp snippet below
> >>  > >
> >>  > >
> >>  > >
> >>  > > Simon
> >>  > >
> >>  > >
> >>  > >
> >>  > > Do you envisage it operating something like this
> >>  > >
> >>  > >
> >>  > >
> >>  > > <h:selectBooleanCheckbox id="selectBusinessType"
> >>  > >
> >>  > > value="#{node.selected}" immediate="true"
> >>  > >
> >>  > > valueChangeListener="#{demo.processValueChange}"
> >>  > >
> >>  > > onclick="submit()" >
> >>  > >
> >>  > > <t:focus componentId="id_of_component_to_focus"/>
> >>  > >
> >>  > > <h:selectBooleanCheckbox >
> >>  > >
> >>  > >
> >>  > >
> >>  > > If NOT, then how – as I can see it being required at several places
> >> on a
> >>  > > form
> >>  > >
> >>  > >
> >>  > >
> >>  > >
> >>  > >
> >>  > > Stefan Maric | IT & Professional Services | BT Global Services
> >>  > >
> >>  > > E: [EMAIL PROTECTED]  |  www.bt.com/globalservices
> >>  > >
> >>  > >
> >>  > >
> >>  > > This electronic message contains information from British
> >> Telecommunications
> >>  > > plc, which may be privileged
> >>  > >
> >>  > > or confidential.  The information is intended for use only by the
> >>  > > individual(s) or entity named above.  If you
> >>  > >
> >>  > > are not the intended recipient, be aware that any disclosure,
> >> copying,
> >>  > > distribution or use of the contents of
> >>  > >
> >>  > > this information is strictly prohibited.  If you have received this
> >>  > > electronic message in error, please notify
> >>  > >
> >>  > > me by telephone or email (to the number or email address above)
> >> immediately.
> >>  > >
> >>  > >
> >>  > >
> >>  > > Activity and use of the British Telecommunications plc e-mail
> >> system is
> >>  > > monitored to secure its effective
> >>  > >
> >>  > > operation and for other lawful business purposes. Communications
> >> using this
> >>  > > system will also be monitored
> >>  > >
> >>  > > and may be recorded to secure effective operation and for other
> >> lawful
> >>  > > business purposes.
> >>  > >
> >>  > >
> >>  > >
> >>  > > British Telecommunications plc. Registered office:  81 Newgate
> >> Street London
> >>  > > EC1A 7AJ   Registered in
> >>  > >
> >>  > > England no:  1800000
> >>  > >
> >>  > >
> >>  >
> >>
> >>
> >>
> >
> >
> >
>
>
>



--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Reply via email to