You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Rottstock, Sven" <Sv...@sungard.de> on 2008/08/13 10:25:53 UTC

[Trinidad] set focus after partial submit

Hi,

i have the following JavaScript code that should execute a partial
submit. After the response is completed the focus should be set on the
input element that have triggered the request.

<tr:inputText label="#{bundle.searchPattern}"
  value="#{myBean.searchPattern}"
  onkeyup="clickButton_afterEnter(event, submitBtn, this);" />

<tr:commandButton id="submitSearch" action="#{myBean.executeSearch}"
  text="#{bundle.search}" partialSubmit="true" />

<tr:table partialTriggers="submitSearch" value="#{myBean.tableData}">
  <!-- my columns goes here -->
</tr:table>

<script type="text/javascript" language="javascript">
  // <![CDATA[
    var submitBtn = window.document.getElementById("submitSearch");
    var lastFocusElem = null;
                                
    function setFocus(state)
    {
      if(state != TrRequestQueue.STATE_BUSY)
      {
        if(lastFocusElem != null)
        {
          lastFocusElem.focus();
          lastFocusElem = null;
        }
 
TrPage.getInstance().getRequestQueue().removeStateChangeListener(setFocu
s);
      }
    }
                                
    function clickButton_afterEnter(evt, button, source)
    {
      evt = (evt) ? evt : (window.event) ? window.event : "";
      var keycode = evt.which ? evt.which : (evt.keyCode) ? evt.keyCode
: window.event.keyCode;
      if(keycode == 13)
      {
        var btn = (button == null) ? submitBtn : button;
        var form = document.forms[0];
        if(btn != null && form != null)
        {
          lastFocusElem = source;
 
TrPage.getInstance().getRequestQueue().addStateChangeListener(setFocus);
          TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
        }
      }
    }
  // ]]>
</script>

Unfortunately the focus is lost from the input field if I have pressed
the enter key and the response was completed.
Does anybody have an idea what is going wrong here?

Regards,

Sven

JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Losungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders, Thorsten Junike, Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey



Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
>> ok, it is not "added" when ppr and navigation.
>
> exactly.

I may take a look at that...

-M

>
>> I wasn't aware of that. :)
>
> no problem! ;-)

-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

AW: [Trinidad] set focus after partial submit

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
> 
JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey

-----Ursprüngliche Nachricht-----
> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im 
> Auftrag von Matthias Wessendorf
> Gesendet: Mittwoch, 13. August 2008 15:16
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] set focus after partial submit
> 
> On Wed, Aug 13, 2008 at 3:07 PM, Matthias Wessendorf 
> <ma...@apache.org> wrote:
> > On Wed, Aug 13, 2008 at 3:00 PM, Matthias Wessendorf 
> <ma...@apache.org> wrote:
> >> On Wed, Aug 13, 2008 at 2:48 PM, Rottstock, Sven 
> >> <Sv...@sungard.de> wrote:
> >>> Yeah - it is working now. Thanks a lot, Matthias.
> >>>
> >>> I have simply added the initialFocusId attribute in the 
> tr:document element. That references to a property in my bean.
> >>>
> >>> Via
> >>>
> >>> TrPage._autoSubmit(form.id, btn.id, evt, true,  
> >>> _addFormParameter(null, 'search.lastFocusElemId', 
> >>> lastFocusElem.id));
> >>>
> >>> is it possible to set the focus id in the action method. 
> >>> Unfortunately the
> >>>
> >>> ExtendedRenderKitService erks = (ExtendedRenderKitService)Service
> >>>            .getRenderKitService(fCtx, 
> >>> ExtendedRenderKitService.class); erks.addScript(fCtx, 
> >>> "_setFocus("+focusId+");");
> >>
> >> do you get any errors?
> > and what does the response look like ?
> 
> ok, it is not "added" when ppr and navigation.

exactly.

> I wasn't aware of that. :)

no problem! ;-)

> 
> -M
> 
> 
> >
> >> But I guess that "alert(...)" works, right?
> >>
> >> -M
> >>
> >>>
> >>> was not working for me :-(
> >>>
> >>> Anyway - now it works like expected.
> >>>
> >>>>
> >>> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . 
> www.sungard.de/finanztag 
> >>> Complexity, Compliance & Cost: Globale Herausforderungen 
> und lokale 
> >>> Lösungen 22. Oktober 2008 . Frankfurt am Main
> >>>
> >>> _______________________________
> >>> Think before you print
> >>> CONFIDENTIALITY: This e-mail (including any attachments) 
> may contain confidential, proprietary and privileged 
> information, and unauthorized disclosure or use is 
> prohibited.  If you receive this e-mail in error, please 
> notify the sender and delete this e-mail from your system.
> >>>
> >>> SunGard Systeme GmbH  Registered Frankfurt am Main, 
> Handelsregister 
> >>> Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten 
> >>> Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth 
> >>> Silbey
> >>>
> >>> -----Ursprüngliche Nachricht-----
> >>>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im 
> >>>> Auftrag von Matthias Wessendorf
> >>>> Gesendet: Mittwoch, 13. August 2008 13:09
> >>>> An: MyFaces Discussion
> >>>> Betreff: Re: [Trinidad] set focus after partial submit
> >>>>
> >>>> On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven 
> >>>> <Sv...@sungard.de> wrote:
> >>>> > Ok - I can test it. But it should be the same when I add an
> >>>> "onload" attribute to the tr:document, isn't it?
> >>>> that would always invoke the func. I understood it like you only 
> >>>> want it sometimes.
> >>>> > Another thing is how can I store the JavaScript variable
> >>>> 'lastFocusElem'? Of course, I can store it in my backing 
> bean...but 
> >>>> I don't know if it is a good option.
> >>>>
> >>>> Perhaps you want to use
> >>>> "TrPage.getInstance().sendPartialFormPost(.........)" 
> for doing the 
> >>>> PPR postback:
> >>>>
> >>>> /**
> >>>>  * Post the form for partial postback.  Supports both 
> standard AJAX
> >>>>  * posts and, for multipart/form posts, IFRAME-based 
> transmission.
> >>>>  * @param actionForm{FormElement} the HTML form to post
> >>>>  * @param params{Object} additional parameters to send
> >>>>  * @param headerParams{Object} HTTP headers to include 
> (ignored if
> >>>>  *   the request must be a multipart/form post)
> >>>>  */
> >>>>   TrPage.getInstance().sendPartialFormPost(
> >>>>      theForm,
> >>>>      {param1: "value1", param2: "value2"},
> >>>>      {header1: "headerValue1", header2: "headerValue2"});
> >>>>
> >>>>
> >>>> so, you can pass in some args.
> >>>>
> >>>> -M
> >>>>
> >>>> >
> >>>> >>
> >>>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . 
> >>>> > www.sungard.de/finanztag Complexity, Compliance & 
> Cost: Globale 
> >>>> > Herausforderungen und lokale Lösungen 22. Oktober 2008 . 
> >>>> > Frankfurt am Main
> >>>> >
> >>>> > _______________________________
> >>>> > Think before you print
> >>>> > CONFIDENTIALITY: This e-mail (including any attachments)
> >>>> may contain confidential, proprietary and privileged 
> information, 
> >>>> and unauthorized disclosure or use is prohibited.  If 
> you receive 
> >>>> this e-mail in error, please notify the sender and delete this 
> >>>> e-mail from your system.
> >>>> >
> >>>> > SunGard Systeme GmbH  Registered Frankfurt am Main, 
> >>>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold 
> >>>> > Finders,
> >>>> Thorsten Junike,
> >>>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >>>> >
> >>>> > -----Ursprüngliche Nachricht-----
> >>>> >> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
> >>>> Im Auftrag
> >>>> >> von Matthias Wessendorf
> >>>> >> Gesendet: Mittwoch, 13. August 2008 12:46
> >>>> >> An: MyFaces Discussion
> >>>> >> Betreff: Re: [Trinidad] set focus after partial submit
> >>>> >>
> >>>> >> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
> >>>> >>
> >>>> >> you even can "add" the function (to do the element.focus)
> >>>> dynamically.
> >>>> >>
> >>>> >> -M
> >>>> >>
> >>>> >> >
> >>>> >> >
> >>>> >> > at the very end of the (ajax) response a <script> tag is 
> >>>> >> > added,
> >>>> >> >
> >>>> >> > like
> >>>> >> >
> >>>> >> > <script id....>doSomeNiceStuff(....)</script>
> >>>> >> >
> >>>> >> > this should work
> >>>> >> >>
> >>>> >> >> Regards,
> >>>> >> >>
> >>>> >> >> Sven
> >>>> >> >>
> >>>> >> >>>
> >>>> >> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >>>> www.sungard.de/finanztag
> >>>> >> >> Complexity, Compliance & Cost: Globale Herausforderungen
> >>>> >> und lokale
> >>>> >> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
> >>>> >> >>
> >>>> >> >> _______________________________ Think before you print
> >>>> >> >> CONFIDENTIALITY: This e-mail (including any attachments)
> >>>> >> may contain confidential, proprietary and privileged
> >>>> information, and
> >>>> >> unauthorized disclosure or use is prohibited.  If you receive 
> >>>> >> this e-mail in error, please notify the sender and delete this
> >>>> e-mail from
> >>>> >> your system.
> >>>> >> >>
> >>>> >> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
> >>>> >> Handelsregister
> >>>> >> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
> >>>> >> Thorsten Junike,
> >>>> >> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth 
> >>>> >> >> Silbey
> >>>> >> >>
> >>>> >> >> -----Ursprüngliche Nachricht-----
> >>>> >> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
> >>>> >> Im Auftrag
> >>>> >> >>> von Matthias Wessendorf
> >>>> >> >>> Gesendet: Mittwoch, 13. August 2008 11:34
> >>>> >> >>> An: MyFaces Discussion
> >>>> >> >>> Betreff: Re: [Trinidad] set focus after partial submit
> >>>> >> >>>
> >>>> >> >>> Sven,
> >>>> >> >>>
> >>>> >> >>> we have a dom-update-listener. From the Trinidad
> >>>> DevGuide ([1]).
> >>>> >> >>>
> >>>> >> >>> Trinidad also lets you get notified when DOM is
> >>>> replaced after an
> >>>> >> >>> AJAX response by adding a "DOM replace listener" 
> on the page:
> >>>> >> >>>
> >>>> >> >>>     function myCallback(oldDom, newDom) { ... }
> >>>> >> >>>
> >>>> >> >>>     
> TrPage.getInstance().addDomReplaceListener(myCallback);
> >>>> >> >>>
> >>>> >> >>> The callback is passed two parameters: the old DOM
> >>>> >> element and the
> >>>> >> >>> new DOM element that is replacing it. This callback is
> >>>> >> invoked after
> >>>> >> >>> the replacement has happened. As with
> >>>> addStateChangeListener(), a
> >>>> >> >>> second argument can be passed if you need a "this" to be
> >>>> >> active when
> >>>> >> >>> your callback is notified.
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> So, when the ppr was handled by the Trinidad client
> >>>> >> engine and the
> >>>> >> >>> dom is replaced. you could "search" for an 
> element, and call 
> >>>> >> >>> "element.focus()".
> >>>> >> >>> Can you try that ?
> >>>> >> >>>
> >>>> >> >>> -Matthias
> >>>> >> >>>
> >>>> >> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
> >>>> >> >>>
> >>>> >> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven 
> >>>> >> >>> <Sv...@sungard.de> wrote:
> >>>> >> >>> > I think I have figured out my issue but I don't 
> know how I
> >>>> >> >>> can fix it.
> >>>> >> >>> > The problem is the action method. It returns an existing
> >>>> >> >>> navigation-rule so that the page is completely refreshed
> >>>> >> after the
> >>>> >> >>> partial submit is done. This is necessary because the
> >>>> >> table could be
> >>>> >> >>> changed (regarding of the column count).
> >>>> >> >>> >
> >>>> >> >>> > Regards,
> >>>> >> >>> >
> >>>> >> >>> > Sven
> >>>> >> >>> >
> >>>> >> >>> >>
> >>>> >> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >>>> >> www.sungard.de/finanztag
> >>>> >> >>> > Complexity, Compliance & Cost: Globale 
> Herausforderungen 
> >>>> >> >>> > und lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
> >>>> >> >>> >
> >>>> >> >>> > _______________________________ Think before you print
> >>>> >> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
> >>>> >> >>> may contain confidential, proprietary and privileged
> >>>> information,
> >>>> >> >>> and unauthorized disclosure or use is prohibited.  If
> >>>> you receive
> >>>> >> >>> this e-mail in error, please notify the sender and delete 
> >>>> >> >>> this e-mail from your system.
> >>>> >> >>> >
> >>>> >> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main, 
> >>>> >> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer 
> >>>> >> >>> > Harold Finders,
> >>>> >> >>> Thorsten Junike,
> >>>> >> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria
> >>>> Elizabeth Silbey
> >>>> >> >>> >
> >>>> >> >>> > -----Ursprüngliche Nachricht-----
> >>>> >> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
> >>>> >> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
> >>>> >> >>> >> An: MyFaces Discussion
> >>>> >> >>> >> Betreff: [Trinidad] set focus after partial submit
> >>>> >> >>> >>
> >>>> >> >>> >> Hi,
> >>>> >> >>> >>
> >>>> >> >>> >> i have the following JavaScript code that 
> should execute 
> >>>> >> >>> >> a partial submit. After the response is completed the
> >>>> >> focus should
> >>>> >> >>> >> be set on the input element that have 
> triggered the request.
> >>>> >> >>> >>
> >>>> >> >>> >> <tr:inputText label="#{bundle.searchPattern}"
> >>>> >> >>> >>   value="#{myBean.searchPattern}"
> >>>> >> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn,
> >>>> this);" />
> >>>> >> >>> >>
> >>>> >> >>> >> <tr:commandButton id="submitSearch"
> >>>> >> >>> action="#{myBean.executeSearch}"
> >>>> >> >>> >>   text="#{bundle.search}" partialSubmit="true" />
> >>>> >> >>> >>
> >>>> >> >>> >> <tr:table partialTriggers="submitSearch"
> >>>> >> >>> value="#{myBean.tableData}">
> >>>> >> >>> >>   <!-- my columns goes here --> </tr:table>
> >>>> >> >>> >>
> >>>> >> >>> >> <script type="text/javascript" language="javascript">
> >>>> >> >>> >>   // <![CDATA[
> >>>> >> >>> >>     var submitBtn =
> >>>> >> window.document.getElementById("submitSearch");
> >>>> >> >>> >>     var lastFocusElem = null;
> >>>> >> >>> >>
> >>>> >> >>> >>     function setFocus(state)
> >>>> >> >>> >>     {
> >>>> >> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
> >>>> >> >>> >>       {
> >>>> >> >>> >>         if(lastFocusElem != null)
> >>>> >> >>> >>         {
> >>>> >> >>> >>           lastFocusElem.focus();
> >>>> >> >>> >>           lastFocusElem = null;
> >>>> >> >>> >>         }
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> TrPage.getInstance().getRequestQueue().removeStateChangeListen
> >>>> >> >>> >> er(setFocu
> >>>> >> >>> >> s);
> >>>> >> >>> >>       }
> >>>> >> >>> >>     }
> >>>> >> >>> >>
> >>>> >> >>> >>     function clickButton_afterEnter(evt, 
> button, source)
> >>>> >> >>> >>     {
> >>>> >> >>> >>       evt = (evt) ? evt : (window.event) ?
> >>>> window.event : "";
> >>>> >> >>> >>       var keycode = evt.which ? evt.which : 
> (evt.keyCode) ?
> >>>> >> >>> >> evt.keyCode
> >>>> >> >>> >> : window.event.keyCode;
> >>>> >> >>> >>       if(keycode == 13)
> >>>> >> >>> >>       {
> >>>> >> >>> >>         var btn = (button == null) ? submitBtn 
> : button;
> >>>> >> >>> >>         var form = document.forms[0];
> >>>> >> >>> >>         if(btn != null && form != null)
> >>>> >> >>> >>         {
> >>>> >> >>> >>           lastFocusElem = source;
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> TrPage.getInstance().getRequestQueue().addStateChangeListener(
> >>>> >> >>> >> setFocus);
> >>>> >> >>> >>           TrPage._autoSubmit(form.id, btn.id, 
> evt, true, 0);
> >>>> >> >>> >>         }
> >>>> >> >>> >>       }
> >>>> >> >>> >>     }
> >>>> >> >>> >>   // ]]>
> >>>> >> >>> >> </script>
> >>>> >> >>> >>
> >>>> >> >>> >> Unfortunately the focus is lost from the input
> >>>> field if I have
> >>>> >> >>> >> pressed the enter key and the response was completed.
> >>>> >> >>> >> Does anybody have an idea what is going wrong here?
> >>>> >> >>> >>
> >>>> >> >>> >> Regards,
> >>>> >> >>> >>
> >>>> >> >>> >> Sven
> >>>> >> >>> >>
> >>>> >> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >>>> >> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
> >>>> >> >>> >> Globale Herausforderungen und lokale Losungen 
> 22. Oktober
> >>>> >> >>> >> 2008 . Frankfurt am Main
> >>>> >> >>> >>
> >>>> >> >>> >> _______________________________ Think before you print
> >>>> >> >>> >> CONFIDENTIALITY: This e-mail (including any 
> attachments)
> >>>> >> >>> may contain
> >>>> >> >>> >> confidential, proprietary and privileged 
> information, and 
> >>>> >> >>> >> unauthorized disclosure or use is prohibited.  If
> >>>> you receive
> >>>> >> >>> >> this e-mail in error, please notify the sender and
> >>>> delete this
> >>>> >> >>> e-mail from
> >>>> >> >>> >> your system.
> >>>> >> >>> >>
> >>>> >> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
> >>>> >> >>> Handelsregister
> >>>> >> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
> >>>> >> >>> Thorsten Junike,
> >>>> >> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria
> >>>> Elizabeth Silbey
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> --
> >>>> >> >>> Matthias Wessendorf
> >>>> >> >>>
> >>>> >> >>> Need JSF and Web 2.0?
> >>>> >> >>> http://code.google.com/p/facesgoodies
> >>>> >> >>>
> >>>> >> >>> further stuff:
> >>>> >> >>> blog: http://matthiaswessendorf.wordpress.com/
> >>>> >> >>> sessions: http://www.slideshare.net/mwessendorf
> >>>> >> >>> mail: matzew-at-apache-dot-org
> >>>> >> >>>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >
> >>>> >> >
> >>>> >> >
> >>>> >> > --
> >>>> >> > Matthias Wessendorf
> >>>> >> >
> >>>> >> > Need JSF and Web 2.0?
> >>>> >> > http://code.google.com/p/facesgoodies
> >>>> >> >
> >>>> >> > further stuff:
> >>>> >> > blog: http://matthiaswessendorf.wordpress.com/
> >>>> >> > sessions: http://www.slideshare.net/mwessendorf
> >>>> >> > mail: matzew-at-apache-dot-org
> >>>> >> >
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Matthias Wessendorf
> >>>> >>
> >>>> >> Need JSF and Web 2.0?
> >>>> >> http://code.google.com/p/facesgoodies
> >>>> >>
> >>>> >> further stuff:
> >>>> >> blog: http://matthiaswessendorf.wordpress.com/
> >>>> >> sessions: http://www.slideshare.net/mwessendorf
> >>>> >> mail: matzew-at-apache-dot-org
> >>>> >>
> >>>> >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Matthias Wessendorf
> >>>>
> >>>> Need JSF and Web 2.0?
> >>>> http://code.google.com/p/facesgoodies
> >>>>
> >>>> further stuff:
> >>>> blog: http://matthiaswessendorf.wordpress.com/
> >>>> sessions: http://www.slideshare.net/mwessendorf
> >>>> mail: matzew-at-apache-dot-org
> >>>>
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> Matthias Wessendorf
> >>
> >> Need JSF and Web 2.0?
> >> http://code.google.com/p/facesgoodies
> >>
> >> further stuff:
> >> blog: http://matthiaswessendorf.wordpress.com/
> >> sessions: http://www.slideshare.net/mwessendorf
> >> mail: matzew-at-apache-dot-org
> >>
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > Need JSF and Web 2.0?
> > http://code.google.com/p/facesgoodies
> >
> > further stuff:
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > mail: matzew-at-apache-dot-org
> >
> 
> 
> 
> --
> Matthias Wessendorf
> 
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
> 
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
> 


Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
On Wed, Aug 13, 2008 at 3:07 PM, Matthias Wessendorf <ma...@apache.org> wrote:
> On Wed, Aug 13, 2008 at 3:00 PM, Matthias Wessendorf <ma...@apache.org> wrote:
>> On Wed, Aug 13, 2008 at 2:48 PM, Rottstock, Sven
>> <Sv...@sungard.de> wrote:
>>> Yeah - it is working now. Thanks a lot, Matthias.
>>>
>>> I have simply added the initialFocusId attribute in the tr:document element. That references to a property in my bean.
>>>
>>> Via
>>>
>>> TrPage._autoSubmit(form.id, btn.id, evt, true,
>>>  _addFormParameter(null, 'search.lastFocusElemId', lastFocusElem.id));
>>>
>>> is it possible to set the focus id in the action method. Unfortunately the
>>>
>>> ExtendedRenderKitService erks = (ExtendedRenderKitService)Service
>>>            .getRenderKitService(fCtx, ExtendedRenderKitService.class);
>>> erks.addScript(fCtx, "_setFocus("+focusId+");");
>>
>> do you get any errors?
> and what does the response look like ?

ok, it is not "added" when ppr and navigation.
I wasn't aware of that. :)

-M


>
>> But I guess that "alert(...)" works, right?
>>
>> -M
>>
>>>
>>> was not working for me :-(
>>>
>>> Anyway - now it works like expected.
>>>
>>>>
>>> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>>> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
>>> 22. Oktober 2008 . Frankfurt am Main
>>>
>>> _______________________________
>>> Think before you print
>>> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>>>
>>> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>>
>>> -----Ursprüngliche Nachricht-----
>>>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>>>> Auftrag von Matthias Wessendorf
>>>> Gesendet: Mittwoch, 13. August 2008 13:09
>>>> An: MyFaces Discussion
>>>> Betreff: Re: [Trinidad] set focus after partial submit
>>>>
>>>> On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven
>>>> <Sv...@sungard.de> wrote:
>>>> > Ok - I can test it. But it should be the same when I add an
>>>> "onload" attribute to the tr:document, isn't it?
>>>> that would always invoke the func. I understood it like you
>>>> only want it sometimes.
>>>> > Another thing is how can I store the JavaScript variable
>>>> 'lastFocusElem'? Of course, I can store it in my backing
>>>> bean...but I don't know if it is a good option.
>>>>
>>>> Perhaps you want to use
>>>> "TrPage.getInstance().sendPartialFormPost(.........)" for
>>>> doing the PPR postback:
>>>>
>>>> /**
>>>>  * Post the form for partial postback.  Supports both standard AJAX
>>>>  * posts and, for multipart/form posts, IFRAME-based transmission.
>>>>  * @param actionForm{FormElement} the HTML form to post
>>>>  * @param params{Object} additional parameters to send
>>>>  * @param headerParams{Object} HTTP headers to include (ignored if
>>>>  *   the request must be a multipart/form post)
>>>>  */
>>>>   TrPage.getInstance().sendPartialFormPost(
>>>>      theForm,
>>>>      {param1: "value1", param2: "value2"},
>>>>      {header1: "headerValue1", header2: "headerValue2"});
>>>>
>>>>
>>>> so, you can pass in some args.
>>>>
>>>> -M
>>>>
>>>> >
>>>> >>
>>>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>>>> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale
>>>> > Lösungen 22. Oktober 2008 . Frankfurt am Main
>>>> >
>>>> > _______________________________
>>>> > Think before you print
>>>> > CONFIDENTIALITY: This e-mail (including any attachments)
>>>> may contain confidential, proprietary and privileged
>>>> information, and unauthorized disclosure or use is
>>>> prohibited.  If you receive this e-mail in error, please
>>>> notify the sender and delete this e-mail from your system.
>>>> >
>>>> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister
>>>> > Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>>>> Thorsten Junike,
>>>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>>> >
>>>> > -----Ursprüngliche Nachricht-----
>>>> >> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>>>> Im Auftrag
>>>> >> von Matthias Wessendorf
>>>> >> Gesendet: Mittwoch, 13. August 2008 12:46
>>>> >> An: MyFaces Discussion
>>>> >> Betreff: Re: [Trinidad] set focus after partial submit
>>>> >>
>>>> >> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
>>>> >>
>>>> >> you even can "add" the function (to do the element.focus)
>>>> dynamically.
>>>> >>
>>>> >> -M
>>>> >>
>>>> >> >
>>>> >> >
>>>> >> > at the very end of the (ajax) response a <script> tag is added,
>>>> >> >
>>>> >> > like
>>>> >> >
>>>> >> > <script id....>doSomeNiceStuff(....)</script>
>>>> >> >
>>>> >> > this should work
>>>> >> >>
>>>> >> >> Regards,
>>>> >> >>
>>>> >> >> Sven
>>>> >> >>
>>>> >> >>>
>>>> >> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>>> www.sungard.de/finanztag
>>>> >> >> Complexity, Compliance & Cost: Globale Herausforderungen
>>>> >> und lokale
>>>> >> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
>>>> >> >>
>>>> >> >> _______________________________
>>>> >> >> Think before you print
>>>> >> >> CONFIDENTIALITY: This e-mail (including any attachments)
>>>> >> may contain confidential, proprietary and privileged
>>>> information, and
>>>> >> unauthorized disclosure or use is prohibited.  If you receive this
>>>> >> e-mail in error, please notify the sender and delete this
>>>> e-mail from
>>>> >> your system.
>>>> >> >>
>>>> >> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>>>> >> Handelsregister
>>>> >> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>>>> >> Thorsten Junike,
>>>> >> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>>> >> >>
>>>> >> >> -----Ursprüngliche Nachricht-----
>>>> >> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>>>> >> Im Auftrag
>>>> >> >>> von Matthias Wessendorf
>>>> >> >>> Gesendet: Mittwoch, 13. August 2008 11:34
>>>> >> >>> An: MyFaces Discussion
>>>> >> >>> Betreff: Re: [Trinidad] set focus after partial submit
>>>> >> >>>
>>>> >> >>> Sven,
>>>> >> >>>
>>>> >> >>> we have a dom-update-listener. From the Trinidad
>>>> DevGuide ([1]).
>>>> >> >>>
>>>> >> >>> Trinidad also lets you get notified when DOM is
>>>> replaced after an
>>>> >> >>> AJAX response by adding a "DOM replace listener" on the page:
>>>> >> >>>
>>>> >> >>>     function myCallback(oldDom, newDom) { ... }
>>>> >> >>>
>>>> >> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>>>> >> >>>
>>>> >> >>> The callback is passed two parameters: the old DOM
>>>> >> element and the
>>>> >> >>> new DOM element that is replacing it. This callback is
>>>> >> invoked after
>>>> >> >>> the replacement has happened. As with
>>>> addStateChangeListener(), a
>>>> >> >>> second argument can be passed if you need a "this" to be
>>>> >> active when
>>>> >> >>> your callback is notified.
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> So, when the ppr was handled by the Trinidad client
>>>> >> engine and the
>>>> >> >>> dom is replaced. you could "search" for an element, and call
>>>> >> >>> "element.focus()".
>>>> >> >>> Can you try that ?
>>>> >> >>>
>>>> >> >>> -Matthias
>>>> >> >>>
>>>> >> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>>>> >> >>>
>>>> >> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>>>> >> >>> <Sv...@sungard.de> wrote:
>>>> >> >>> > I think I have figured out my issue but I don't know how I
>>>> >> >>> can fix it.
>>>> >> >>> > The problem is the action method. It returns an existing
>>>> >> >>> navigation-rule so that the page is completely refreshed
>>>> >> after the
>>>> >> >>> partial submit is done. This is necessary because the
>>>> >> table could be
>>>> >> >>> changed (regarding of the column count).
>>>> >> >>> >
>>>> >> >>> > Regards,
>>>> >> >>> >
>>>> >> >>> > Sven
>>>> >> >>> >
>>>> >> >>> >>
>>>> >> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>>> >> www.sungard.de/finanztag
>>>> >> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und
>>>> >> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
>>>> >> >>> >
>>>> >> >>> > _______________________________ Think before you print
>>>> >> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
>>>> >> >>> may contain confidential, proprietary and privileged
>>>> information,
>>>> >> >>> and unauthorized disclosure or use is prohibited.  If
>>>> you receive
>>>> >> >>> this e-mail in error, please notify the sender and delete this
>>>> >> >>> e-mail from your system.
>>>> >> >>> >
>>>> >> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main,
>>>> >> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold
>>>> >> >>> > Finders,
>>>> >> >>> Thorsten Junike,
>>>> >> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria
>>>> Elizabeth Silbey
>>>> >> >>> >
>>>> >> >>> > -----Ursprüngliche Nachricht-----
>>>> >> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>>>> >> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>>>> >> >>> >> An: MyFaces Discussion
>>>> >> >>> >> Betreff: [Trinidad] set focus after partial submit
>>>> >> >>> >>
>>>> >> >>> >> Hi,
>>>> >> >>> >>
>>>> >> >>> >> i have the following JavaScript code that should execute a
>>>> >> >>> >> partial submit. After the response is completed the
>>>> >> focus should
>>>> >> >>> >> be set on the input element that have triggered the request.
>>>> >> >>> >>
>>>> >> >>> >> <tr:inputText label="#{bundle.searchPattern}"
>>>> >> >>> >>   value="#{myBean.searchPattern}"
>>>> >> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn,
>>>> this);" />
>>>> >> >>> >>
>>>> >> >>> >> <tr:commandButton id="submitSearch"
>>>> >> >>> action="#{myBean.executeSearch}"
>>>> >> >>> >>   text="#{bundle.search}" partialSubmit="true" />
>>>> >> >>> >>
>>>> >> >>> >> <tr:table partialTriggers="submitSearch"
>>>> >> >>> value="#{myBean.tableData}">
>>>> >> >>> >>   <!-- my columns goes here --> </tr:table>
>>>> >> >>> >>
>>>> >> >>> >> <script type="text/javascript" language="javascript">
>>>> >> >>> >>   // <![CDATA[
>>>> >> >>> >>     var submitBtn =
>>>> >> window.document.getElementById("submitSearch");
>>>> >> >>> >>     var lastFocusElem = null;
>>>> >> >>> >>
>>>> >> >>> >>     function setFocus(state)
>>>> >> >>> >>     {
>>>> >> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
>>>> >> >>> >>       {
>>>> >> >>> >>         if(lastFocusElem != null)
>>>> >> >>> >>         {
>>>> >> >>> >>           lastFocusElem.focus();
>>>> >> >>> >>           lastFocusElem = null;
>>>> >> >>> >>         }
>>>> >> >>> >>
>>>> >> >>> >>
>>>> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>>>> >> >>> >> er(setFocu
>>>> >> >>> >> s);
>>>> >> >>> >>       }
>>>> >> >>> >>     }
>>>> >> >>> >>
>>>> >> >>> >>     function clickButton_afterEnter(evt, button, source)
>>>> >> >>> >>     {
>>>> >> >>> >>       evt = (evt) ? evt : (window.event) ?
>>>> window.event : "";
>>>> >> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>>>> >> >>> >> evt.keyCode
>>>> >> >>> >> : window.event.keyCode;
>>>> >> >>> >>       if(keycode == 13)
>>>> >> >>> >>       {
>>>> >> >>> >>         var btn = (button == null) ? submitBtn : button;
>>>> >> >>> >>         var form = document.forms[0];
>>>> >> >>> >>         if(btn != null && form != null)
>>>> >> >>> >>         {
>>>> >> >>> >>           lastFocusElem = source;
>>>> >> >>> >>
>>>> >> >>> >>
>>>> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>>>> >> >>> >> setFocus);
>>>> >> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>>>> >> >>> >>         }
>>>> >> >>> >>       }
>>>> >> >>> >>     }
>>>> >> >>> >>   // ]]>
>>>> >> >>> >> </script>
>>>> >> >>> >>
>>>> >> >>> >> Unfortunately the focus is lost from the input
>>>> field if I have
>>>> >> >>> >> pressed the enter key and the response was completed.
>>>> >> >>> >> Does anybody have an idea what is going wrong here?
>>>> >> >>> >>
>>>> >> >>> >> Regards,
>>>> >> >>> >>
>>>> >> >>> >> Sven
>>>> >> >>> >>
>>>> >> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>>> >> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>>>> >> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>>>> >> >>> >> 2008 . Frankfurt am Main
>>>> >> >>> >>
>>>> >> >>> >> _______________________________ Think before you print
>>>> >> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>>>> >> >>> may contain
>>>> >> >>> >> confidential, proprietary and privileged information, and
>>>> >> >>> >> unauthorized disclosure or use is prohibited.  If
>>>> you receive
>>>> >> >>> >> this e-mail in error, please notify the sender and
>>>> delete this
>>>> >> >>> e-mail from
>>>> >> >>> >> your system.
>>>> >> >>> >>
>>>> >> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>>>> >> >>> Handelsregister
>>>> >> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>>>> >> >>> Thorsten Junike,
>>>> >> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria
>>>> Elizabeth Silbey
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >
>>>> >> >>> >
>>>> >> >>>
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> --
>>>> >> >>> Matthias Wessendorf
>>>> >> >>>
>>>> >> >>> Need JSF and Web 2.0?
>>>> >> >>> http://code.google.com/p/facesgoodies
>>>> >> >>>
>>>> >> >>> further stuff:
>>>> >> >>> blog: http://matthiaswessendorf.wordpress.com/
>>>> >> >>> sessions: http://www.slideshare.net/mwessendorf
>>>> >> >>> mail: matzew-at-apache-dot-org
>>>> >> >>>
>>>> >> >>
>>>> >> >>
>>>> >> >
>>>> >> >
>>>> >> >
>>>> >> > --
>>>> >> > Matthias Wessendorf
>>>> >> >
>>>> >> > Need JSF and Web 2.0?
>>>> >> > http://code.google.com/p/facesgoodies
>>>> >> >
>>>> >> > further stuff:
>>>> >> > blog: http://matthiaswessendorf.wordpress.com/
>>>> >> > sessions: http://www.slideshare.net/mwessendorf
>>>> >> > mail: matzew-at-apache-dot-org
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Matthias Wessendorf
>>>> >>
>>>> >> Need JSF and Web 2.0?
>>>> >> http://code.google.com/p/facesgoodies
>>>> >>
>>>> >> further stuff:
>>>> >> blog: http://matthiaswessendorf.wordpress.com/
>>>> >> sessions: http://www.slideshare.net/mwessendorf
>>>> >> mail: matzew-at-apache-dot-org
>>>> >>
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Matthias Wessendorf
>>>>
>>>> Need JSF and Web 2.0?
>>>> http://code.google.com/p/facesgoodies
>>>>
>>>> further stuff:
>>>> blog: http://matthiaswessendorf.wordpress.com/
>>>> sessions: http://www.slideshare.net/mwessendorf
>>>> mail: matzew-at-apache-dot-org
>>>>
>>>
>>>
>>
>>
>>
>> --
>> Matthias Wessendorf
>>
>> Need JSF and Web 2.0?
>> http://code.google.com/p/facesgoodies
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
>
>
>
> --
> Matthias Wessendorf
>
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
On Wed, Aug 13, 2008 at 3:00 PM, Matthias Wessendorf <ma...@apache.org> wrote:
> On Wed, Aug 13, 2008 at 2:48 PM, Rottstock, Sven
> <Sv...@sungard.de> wrote:
>> Yeah - it is working now. Thanks a lot, Matthias.
>>
>> I have simply added the initialFocusId attribute in the tr:document element. That references to a property in my bean.
>>
>> Via
>>
>> TrPage._autoSubmit(form.id, btn.id, evt, true,
>>  _addFormParameter(null, 'search.lastFocusElemId', lastFocusElem.id));
>>
>> is it possible to set the focus id in the action method. Unfortunately the
>>
>> ExtendedRenderKitService erks = (ExtendedRenderKitService)Service
>>            .getRenderKitService(fCtx, ExtendedRenderKitService.class);
>> erks.addScript(fCtx, "_setFocus("+focusId+");");
>
> do you get any errors?
and what does the response look like ?

> But I guess that "alert(...)" works, right?
>
> -M
>
>>
>> was not working for me :-(
>>
>> Anyway - now it works like expected.
>>
>>>
>> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
>> 22. Oktober 2008 . Frankfurt am Main
>>
>> _______________________________
>> Think before you print
>> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>>
>> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>
>> -----Ursprüngliche Nachricht-----
>>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>>> Auftrag von Matthias Wessendorf
>>> Gesendet: Mittwoch, 13. August 2008 13:09
>>> An: MyFaces Discussion
>>> Betreff: Re: [Trinidad] set focus after partial submit
>>>
>>> On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven
>>> <Sv...@sungard.de> wrote:
>>> > Ok - I can test it. But it should be the same when I add an
>>> "onload" attribute to the tr:document, isn't it?
>>> that would always invoke the func. I understood it like you
>>> only want it sometimes.
>>> > Another thing is how can I store the JavaScript variable
>>> 'lastFocusElem'? Of course, I can store it in my backing
>>> bean...but I don't know if it is a good option.
>>>
>>> Perhaps you want to use
>>> "TrPage.getInstance().sendPartialFormPost(.........)" for
>>> doing the PPR postback:
>>>
>>> /**
>>>  * Post the form for partial postback.  Supports both standard AJAX
>>>  * posts and, for multipart/form posts, IFRAME-based transmission.
>>>  * @param actionForm{FormElement} the HTML form to post
>>>  * @param params{Object} additional parameters to send
>>>  * @param headerParams{Object} HTTP headers to include (ignored if
>>>  *   the request must be a multipart/form post)
>>>  */
>>>   TrPage.getInstance().sendPartialFormPost(
>>>      theForm,
>>>      {param1: "value1", param2: "value2"},
>>>      {header1: "headerValue1", header2: "headerValue2"});
>>>
>>>
>>> so, you can pass in some args.
>>>
>>> -M
>>>
>>> >
>>> >>
>>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>>> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale
>>> > Lösungen 22. Oktober 2008 . Frankfurt am Main
>>> >
>>> > _______________________________
>>> > Think before you print
>>> > CONFIDENTIALITY: This e-mail (including any attachments)
>>> may contain confidential, proprietary and privileged
>>> information, and unauthorized disclosure or use is
>>> prohibited.  If you receive this e-mail in error, please
>>> notify the sender and delete this e-mail from your system.
>>> >
>>> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister
>>> > Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>>> Thorsten Junike,
>>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>> >
>>> > -----Ursprüngliche Nachricht-----
>>> >> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>>> Im Auftrag
>>> >> von Matthias Wessendorf
>>> >> Gesendet: Mittwoch, 13. August 2008 12:46
>>> >> An: MyFaces Discussion
>>> >> Betreff: Re: [Trinidad] set focus after partial submit
>>> >>
>>> >> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
>>> >>
>>> >> you even can "add" the function (to do the element.focus)
>>> dynamically.
>>> >>
>>> >> -M
>>> >>
>>> >> >
>>> >> >
>>> >> > at the very end of the (ajax) response a <script> tag is added,
>>> >> >
>>> >> > like
>>> >> >
>>> >> > <script id....>doSomeNiceStuff(....)</script>
>>> >> >
>>> >> > this should work
>>> >> >>
>>> >> >> Regards,
>>> >> >>
>>> >> >> Sven
>>> >> >>
>>> >> >>>
>>> >> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>> www.sungard.de/finanztag
>>> >> >> Complexity, Compliance & Cost: Globale Herausforderungen
>>> >> und lokale
>>> >> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
>>> >> >>
>>> >> >> _______________________________
>>> >> >> Think before you print
>>> >> >> CONFIDENTIALITY: This e-mail (including any attachments)
>>> >> may contain confidential, proprietary and privileged
>>> information, and
>>> >> unauthorized disclosure or use is prohibited.  If you receive this
>>> >> e-mail in error, please notify the sender and delete this
>>> e-mail from
>>> >> your system.
>>> >> >>
>>> >> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>>> >> Handelsregister
>>> >> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>>> >> Thorsten Junike,
>>> >> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>> >> >>
>>> >> >> -----Ursprüngliche Nachricht-----
>>> >> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>>> >> Im Auftrag
>>> >> >>> von Matthias Wessendorf
>>> >> >>> Gesendet: Mittwoch, 13. August 2008 11:34
>>> >> >>> An: MyFaces Discussion
>>> >> >>> Betreff: Re: [Trinidad] set focus after partial submit
>>> >> >>>
>>> >> >>> Sven,
>>> >> >>>
>>> >> >>> we have a dom-update-listener. From the Trinidad
>>> DevGuide ([1]).
>>> >> >>>
>>> >> >>> Trinidad also lets you get notified when DOM is
>>> replaced after an
>>> >> >>> AJAX response by adding a "DOM replace listener" on the page:
>>> >> >>>
>>> >> >>>     function myCallback(oldDom, newDom) { ... }
>>> >> >>>
>>> >> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>>> >> >>>
>>> >> >>> The callback is passed two parameters: the old DOM
>>> >> element and the
>>> >> >>> new DOM element that is replacing it. This callback is
>>> >> invoked after
>>> >> >>> the replacement has happened. As with
>>> addStateChangeListener(), a
>>> >> >>> second argument can be passed if you need a "this" to be
>>> >> active when
>>> >> >>> your callback is notified.
>>> >> >>>
>>> >> >>>
>>> >> >>> So, when the ppr was handled by the Trinidad client
>>> >> engine and the
>>> >> >>> dom is replaced. you could "search" for an element, and call
>>> >> >>> "element.focus()".
>>> >> >>> Can you try that ?
>>> >> >>>
>>> >> >>> -Matthias
>>> >> >>>
>>> >> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>>> >> >>>
>>> >> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>>> >> >>> <Sv...@sungard.de> wrote:
>>> >> >>> > I think I have figured out my issue but I don't know how I
>>> >> >>> can fix it.
>>> >> >>> > The problem is the action method. It returns an existing
>>> >> >>> navigation-rule so that the page is completely refreshed
>>> >> after the
>>> >> >>> partial submit is done. This is necessary because the
>>> >> table could be
>>> >> >>> changed (regarding of the column count).
>>> >> >>> >
>>> >> >>> > Regards,
>>> >> >>> >
>>> >> >>> > Sven
>>> >> >>> >
>>> >> >>> >>
>>> >> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>> >> www.sungard.de/finanztag
>>> >> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und
>>> >> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
>>> >> >>> >
>>> >> >>> > _______________________________ Think before you print
>>> >> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
>>> >> >>> may contain confidential, proprietary and privileged
>>> information,
>>> >> >>> and unauthorized disclosure or use is prohibited.  If
>>> you receive
>>> >> >>> this e-mail in error, please notify the sender and delete this
>>> >> >>> e-mail from your system.
>>> >> >>> >
>>> >> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main,
>>> >> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold
>>> >> >>> > Finders,
>>> >> >>> Thorsten Junike,
>>> >> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria
>>> Elizabeth Silbey
>>> >> >>> >
>>> >> >>> > -----Ursprüngliche Nachricht-----
>>> >> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>>> >> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>>> >> >>> >> An: MyFaces Discussion
>>> >> >>> >> Betreff: [Trinidad] set focus after partial submit
>>> >> >>> >>
>>> >> >>> >> Hi,
>>> >> >>> >>
>>> >> >>> >> i have the following JavaScript code that should execute a
>>> >> >>> >> partial submit. After the response is completed the
>>> >> focus should
>>> >> >>> >> be set on the input element that have triggered the request.
>>> >> >>> >>
>>> >> >>> >> <tr:inputText label="#{bundle.searchPattern}"
>>> >> >>> >>   value="#{myBean.searchPattern}"
>>> >> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn,
>>> this);" />
>>> >> >>> >>
>>> >> >>> >> <tr:commandButton id="submitSearch"
>>> >> >>> action="#{myBean.executeSearch}"
>>> >> >>> >>   text="#{bundle.search}" partialSubmit="true" />
>>> >> >>> >>
>>> >> >>> >> <tr:table partialTriggers="submitSearch"
>>> >> >>> value="#{myBean.tableData}">
>>> >> >>> >>   <!-- my columns goes here --> </tr:table>
>>> >> >>> >>
>>> >> >>> >> <script type="text/javascript" language="javascript">
>>> >> >>> >>   // <![CDATA[
>>> >> >>> >>     var submitBtn =
>>> >> window.document.getElementById("submitSearch");
>>> >> >>> >>     var lastFocusElem = null;
>>> >> >>> >>
>>> >> >>> >>     function setFocus(state)
>>> >> >>> >>     {
>>> >> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
>>> >> >>> >>       {
>>> >> >>> >>         if(lastFocusElem != null)
>>> >> >>> >>         {
>>> >> >>> >>           lastFocusElem.focus();
>>> >> >>> >>           lastFocusElem = null;
>>> >> >>> >>         }
>>> >> >>> >>
>>> >> >>> >>
>>> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>>> >> >>> >> er(setFocu
>>> >> >>> >> s);
>>> >> >>> >>       }
>>> >> >>> >>     }
>>> >> >>> >>
>>> >> >>> >>     function clickButton_afterEnter(evt, button, source)
>>> >> >>> >>     {
>>> >> >>> >>       evt = (evt) ? evt : (window.event) ?
>>> window.event : "";
>>> >> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>>> >> >>> >> evt.keyCode
>>> >> >>> >> : window.event.keyCode;
>>> >> >>> >>       if(keycode == 13)
>>> >> >>> >>       {
>>> >> >>> >>         var btn = (button == null) ? submitBtn : button;
>>> >> >>> >>         var form = document.forms[0];
>>> >> >>> >>         if(btn != null && form != null)
>>> >> >>> >>         {
>>> >> >>> >>           lastFocusElem = source;
>>> >> >>> >>
>>> >> >>> >>
>>> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>>> >> >>> >> setFocus);
>>> >> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>>> >> >>> >>         }
>>> >> >>> >>       }
>>> >> >>> >>     }
>>> >> >>> >>   // ]]>
>>> >> >>> >> </script>
>>> >> >>> >>
>>> >> >>> >> Unfortunately the focus is lost from the input
>>> field if I have
>>> >> >>> >> pressed the enter key and the response was completed.
>>> >> >>> >> Does anybody have an idea what is going wrong here?
>>> >> >>> >>
>>> >> >>> >> Regards,
>>> >> >>> >>
>>> >> >>> >> Sven
>>> >> >>> >>
>>> >> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>> >> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>>> >> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>>> >> >>> >> 2008 . Frankfurt am Main
>>> >> >>> >>
>>> >> >>> >> _______________________________ Think before you print
>>> >> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>>> >> >>> may contain
>>> >> >>> >> confidential, proprietary and privileged information, and
>>> >> >>> >> unauthorized disclosure or use is prohibited.  If
>>> you receive
>>> >> >>> >> this e-mail in error, please notify the sender and
>>> delete this
>>> >> >>> e-mail from
>>> >> >>> >> your system.
>>> >> >>> >>
>>> >> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>>> >> >>> Handelsregister
>>> >> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>>> >> >>> Thorsten Junike,
>>> >> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria
>>> Elizabeth Silbey
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >
>>> >> >>> >
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> Matthias Wessendorf
>>> >> >>>
>>> >> >>> Need JSF and Web 2.0?
>>> >> >>> http://code.google.com/p/facesgoodies
>>> >> >>>
>>> >> >>> further stuff:
>>> >> >>> blog: http://matthiaswessendorf.wordpress.com/
>>> >> >>> sessions: http://www.slideshare.net/mwessendorf
>>> >> >>> mail: matzew-at-apache-dot-org
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >> >
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Matthias Wessendorf
>>> >> >
>>> >> > Need JSF and Web 2.0?
>>> >> > http://code.google.com/p/facesgoodies
>>> >> >
>>> >> > further stuff:
>>> >> > blog: http://matthiaswessendorf.wordpress.com/
>>> >> > sessions: http://www.slideshare.net/mwessendorf
>>> >> > mail: matzew-at-apache-dot-org
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Matthias Wessendorf
>>> >>
>>> >> Need JSF and Web 2.0?
>>> >> http://code.google.com/p/facesgoodies
>>> >>
>>> >> further stuff:
>>> >> blog: http://matthiaswessendorf.wordpress.com/
>>> >> sessions: http://www.slideshare.net/mwessendorf
>>> >> mail: matzew-at-apache-dot-org
>>> >>
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Matthias Wessendorf
>>>
>>> Need JSF and Web 2.0?
>>> http://code.google.com/p/facesgoodies
>>>
>>> further stuff:
>>> blog: http://matthiaswessendorf.wordpress.com/
>>> sessions: http://www.slideshare.net/mwessendorf
>>> mail: matzew-at-apache-dot-org
>>>
>>
>>
>
>
>
> --
> Matthias Wessendorf
>
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
On Wed, Aug 13, 2008 at 2:48 PM, Rottstock, Sven
<Sv...@sungard.de> wrote:
> Yeah - it is working now. Thanks a lot, Matthias.
>
> I have simply added the initialFocusId attribute in the tr:document element. That references to a property in my bean.
>
> Via
>
> TrPage._autoSubmit(form.id, btn.id, evt, true,
>  _addFormParameter(null, 'search.lastFocusElemId', lastFocusElem.id));
>
> is it possible to set the focus id in the action method. Unfortunately the
>
> ExtendedRenderKitService erks = (ExtendedRenderKitService)Service
>            .getRenderKitService(fCtx, ExtendedRenderKitService.class);
> erks.addScript(fCtx, "_setFocus("+focusId+");");

do you get any errors?
But I guess that "alert(...)" works, right?

-M

>
> was not working for me :-(
>
> Anyway - now it works like expected.
>
>>
> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
> 22. Oktober 2008 . Frankfurt am Main
>
> _______________________________
> Think before you print
> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>
> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>
> -----Ursprüngliche Nachricht-----
>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>> Auftrag von Matthias Wessendorf
>> Gesendet: Mittwoch, 13. August 2008 13:09
>> An: MyFaces Discussion
>> Betreff: Re: [Trinidad] set focus after partial submit
>>
>> On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven
>> <Sv...@sungard.de> wrote:
>> > Ok - I can test it. But it should be the same when I add an
>> "onload" attribute to the tr:document, isn't it?
>> that would always invoke the func. I understood it like you
>> only want it sometimes.
>> > Another thing is how can I store the JavaScript variable
>> 'lastFocusElem'? Of course, I can store it in my backing
>> bean...but I don't know if it is a good option.
>>
>> Perhaps you want to use
>> "TrPage.getInstance().sendPartialFormPost(.........)" for
>> doing the PPR postback:
>>
>> /**
>>  * Post the form for partial postback.  Supports both standard AJAX
>>  * posts and, for multipart/form posts, IFRAME-based transmission.
>>  * @param actionForm{FormElement} the HTML form to post
>>  * @param params{Object} additional parameters to send
>>  * @param headerParams{Object} HTTP headers to include (ignored if
>>  *   the request must be a multipart/form post)
>>  */
>>   TrPage.getInstance().sendPartialFormPost(
>>      theForm,
>>      {param1: "value1", param2: "value2"},
>>      {header1: "headerValue1", header2: "headerValue2"});
>>
>>
>> so, you can pass in some args.
>>
>> -M
>>
>> >
>> >>
>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale
>> > Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >
>> > _______________________________
>> > Think before you print
>> > CONFIDENTIALITY: This e-mail (including any attachments)
>> may contain confidential, proprietary and privileged
>> information, and unauthorized disclosure or use is
>> prohibited.  If you receive this e-mail in error, please
>> notify the sender and delete this e-mail from your system.
>> >
>> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister
>> > Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>> Thorsten Junike,
>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >
>> > -----Ursprüngliche Nachricht-----
>> >> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>> Im Auftrag
>> >> von Matthias Wessendorf
>> >> Gesendet: Mittwoch, 13. August 2008 12:46
>> >> An: MyFaces Discussion
>> >> Betreff: Re: [Trinidad] set focus after partial submit
>> >>
>> >> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
>> >>
>> >> you even can "add" the function (to do the element.focus)
>> dynamically.
>> >>
>> >> -M
>> >>
>> >> >
>> >> >
>> >> > at the very end of the (ajax) response a <script> tag is added,
>> >> >
>> >> > like
>> >> >
>> >> > <script id....>doSomeNiceStuff(....)</script>
>> >> >
>> >> > this should work
>> >> >>
>> >> >> Regards,
>> >> >>
>> >> >> Sven
>> >> >>
>> >> >>>
>> >> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> www.sungard.de/finanztag
>> >> >> Complexity, Compliance & Cost: Globale Herausforderungen
>> >> und lokale
>> >> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >> >>
>> >> >> _______________________________
>> >> >> Think before you print
>> >> >> CONFIDENTIALITY: This e-mail (including any attachments)
>> >> may contain confidential, proprietary and privileged
>> information, and
>> >> unauthorized disclosure or use is prohibited.  If you receive this
>> >> e-mail in error, please notify the sender and delete this
>> e-mail from
>> >> your system.
>> >> >>
>> >> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> >> Handelsregister
>> >> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>> >> Thorsten Junike,
>> >> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >> >>
>> >> >> -----Ursprüngliche Nachricht-----
>> >> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>> >> Im Auftrag
>> >> >>> von Matthias Wessendorf
>> >> >>> Gesendet: Mittwoch, 13. August 2008 11:34
>> >> >>> An: MyFaces Discussion
>> >> >>> Betreff: Re: [Trinidad] set focus after partial submit
>> >> >>>
>> >> >>> Sven,
>> >> >>>
>> >> >>> we have a dom-update-listener. From the Trinidad
>> DevGuide ([1]).
>> >> >>>
>> >> >>> Trinidad also lets you get notified when DOM is
>> replaced after an
>> >> >>> AJAX response by adding a "DOM replace listener" on the page:
>> >> >>>
>> >> >>>     function myCallback(oldDom, newDom) { ... }
>> >> >>>
>> >> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>> >> >>>
>> >> >>> The callback is passed two parameters: the old DOM
>> >> element and the
>> >> >>> new DOM element that is replacing it. This callback is
>> >> invoked after
>> >> >>> the replacement has happened. As with
>> addStateChangeListener(), a
>> >> >>> second argument can be passed if you need a "this" to be
>> >> active when
>> >> >>> your callback is notified.
>> >> >>>
>> >> >>>
>> >> >>> So, when the ppr was handled by the Trinidad client
>> >> engine and the
>> >> >>> dom is replaced. you could "search" for an element, and call
>> >> >>> "element.focus()".
>> >> >>> Can you try that ?
>> >> >>>
>> >> >>> -Matthias
>> >> >>>
>> >> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>> >> >>>
>> >> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>> >> >>> <Sv...@sungard.de> wrote:
>> >> >>> > I think I have figured out my issue but I don't know how I
>> >> >>> can fix it.
>> >> >>> > The problem is the action method. It returns an existing
>> >> >>> navigation-rule so that the page is completely refreshed
>> >> after the
>> >> >>> partial submit is done. This is necessary because the
>> >> table could be
>> >> >>> changed (regarding of the column count).
>> >> >>> >
>> >> >>> > Regards,
>> >> >>> >
>> >> >>> > Sven
>> >> >>> >
>> >> >>> >>
>> >> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> >> www.sungard.de/finanztag
>> >> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und
>> >> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >> >>> >
>> >> >>> > _______________________________ Think before you print
>> >> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
>> >> >>> may contain confidential, proprietary and privileged
>> information,
>> >> >>> and unauthorized disclosure or use is prohibited.  If
>> you receive
>> >> >>> this e-mail in error, please notify the sender and delete this
>> >> >>> e-mail from your system.
>> >> >>> >
>> >> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main,
>> >> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold
>> >> >>> > Finders,
>> >> >>> Thorsten Junike,
>> >> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria
>> Elizabeth Silbey
>> >> >>> >
>> >> >>> > -----Ursprüngliche Nachricht-----
>> >> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>> >> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>> >> >>> >> An: MyFaces Discussion
>> >> >>> >> Betreff: [Trinidad] set focus after partial submit
>> >> >>> >>
>> >> >>> >> Hi,
>> >> >>> >>
>> >> >>> >> i have the following JavaScript code that should execute a
>> >> >>> >> partial submit. After the response is completed the
>> >> focus should
>> >> >>> >> be set on the input element that have triggered the request.
>> >> >>> >>
>> >> >>> >> <tr:inputText label="#{bundle.searchPattern}"
>> >> >>> >>   value="#{myBean.searchPattern}"
>> >> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn,
>> this);" />
>> >> >>> >>
>> >> >>> >> <tr:commandButton id="submitSearch"
>> >> >>> action="#{myBean.executeSearch}"
>> >> >>> >>   text="#{bundle.search}" partialSubmit="true" />
>> >> >>> >>
>> >> >>> >> <tr:table partialTriggers="submitSearch"
>> >> >>> value="#{myBean.tableData}">
>> >> >>> >>   <!-- my columns goes here --> </tr:table>
>> >> >>> >>
>> >> >>> >> <script type="text/javascript" language="javascript">
>> >> >>> >>   // <![CDATA[
>> >> >>> >>     var submitBtn =
>> >> window.document.getElementById("submitSearch");
>> >> >>> >>     var lastFocusElem = null;
>> >> >>> >>
>> >> >>> >>     function setFocus(state)
>> >> >>> >>     {
>> >> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
>> >> >>> >>       {
>> >> >>> >>         if(lastFocusElem != null)
>> >> >>> >>         {
>> >> >>> >>           lastFocusElem.focus();
>> >> >>> >>           lastFocusElem = null;
>> >> >>> >>         }
>> >> >>> >>
>> >> >>> >>
>> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>> >> >>> >> er(setFocu
>> >> >>> >> s);
>> >> >>> >>       }
>> >> >>> >>     }
>> >> >>> >>
>> >> >>> >>     function clickButton_afterEnter(evt, button, source)
>> >> >>> >>     {
>> >> >>> >>       evt = (evt) ? evt : (window.event) ?
>> window.event : "";
>> >> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>> >> >>> >> evt.keyCode
>> >> >>> >> : window.event.keyCode;
>> >> >>> >>       if(keycode == 13)
>> >> >>> >>       {
>> >> >>> >>         var btn = (button == null) ? submitBtn : button;
>> >> >>> >>         var form = document.forms[0];
>> >> >>> >>         if(btn != null && form != null)
>> >> >>> >>         {
>> >> >>> >>           lastFocusElem = source;
>> >> >>> >>
>> >> >>> >>
>> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>> >> >>> >> setFocus);
>> >> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>> >> >>> >>         }
>> >> >>> >>       }
>> >> >>> >>     }
>> >> >>> >>   // ]]>
>> >> >>> >> </script>
>> >> >>> >>
>> >> >>> >> Unfortunately the focus is lost from the input
>> field if I have
>> >> >>> >> pressed the enter key and the response was completed.
>> >> >>> >> Does anybody have an idea what is going wrong here?
>> >> >>> >>
>> >> >>> >> Regards,
>> >> >>> >>
>> >> >>> >> Sven
>> >> >>> >>
>> >> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> >> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>> >> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>> >> >>> >> 2008 . Frankfurt am Main
>> >> >>> >>
>> >> >>> >> _______________________________ Think before you print
>> >> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>> >> >>> may contain
>> >> >>> >> confidential, proprietary and privileged information, and
>> >> >>> >> unauthorized disclosure or use is prohibited.  If
>> you receive
>> >> >>> >> this e-mail in error, please notify the sender and
>> delete this
>> >> >>> e-mail from
>> >> >>> >> your system.
>> >> >>> >>
>> >> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> >> >>> Handelsregister
>> >> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>> >> >>> Thorsten Junike,
>> >> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria
>> Elizabeth Silbey
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Matthias Wessendorf
>> >> >>>
>> >> >>> Need JSF and Web 2.0?
>> >> >>> http://code.google.com/p/facesgoodies
>> >> >>>
>> >> >>> further stuff:
>> >> >>> blog: http://matthiaswessendorf.wordpress.com/
>> >> >>> sessions: http://www.slideshare.net/mwessendorf
>> >> >>> mail: matzew-at-apache-dot-org
>> >> >>>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Matthias Wessendorf
>> >> >
>> >> > Need JSF and Web 2.0?
>> >> > http://code.google.com/p/facesgoodies
>> >> >
>> >> > further stuff:
>> >> > blog: http://matthiaswessendorf.wordpress.com/
>> >> > sessions: http://www.slideshare.net/mwessendorf
>> >> > mail: matzew-at-apache-dot-org
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Matthias Wessendorf
>> >>
>> >> Need JSF and Web 2.0?
>> >> http://code.google.com/p/facesgoodies
>> >>
>> >> further stuff:
>> >> blog: http://matthiaswessendorf.wordpress.com/
>> >> sessions: http://www.slideshare.net/mwessendorf
>> >> mail: matzew-at-apache-dot-org
>> >>
>> >
>> >
>>
>>
>>
>> --
>> Matthias Wessendorf
>>
>> Need JSF and Web 2.0?
>> http://code.google.com/p/facesgoodies
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
>
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

AW: [Trinidad] set focus after partial submit

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Yeah - it is working now. Thanks a lot, Matthias.

I have simply added the initialFocusId attribute in the tr:document element. That references to a property in my bean.

Via 

TrPage._autoSubmit(form.id, btn.id, evt, true, 
  _addFormParameter(null, 'search.lastFocusElemId', lastFocusElem.id));

is it possible to set the focus id in the action method. Unfortunately the

ExtendedRenderKitService erks = (ExtendedRenderKitService)Service
            .getRenderKitService(fCtx, ExtendedRenderKitService.class);
erks.addScript(fCtx, "_setFocus("+focusId+");");

was not working for me :-(

Anyway - now it works like expected.

> 
JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey

-----Ursprüngliche Nachricht-----
> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im 
> Auftrag von Matthias Wessendorf
> Gesendet: Mittwoch, 13. August 2008 13:09
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] set focus after partial submit
> 
> On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven 
> <Sv...@sungard.de> wrote:
> > Ok - I can test it. But it should be the same when I add an 
> "onload" attribute to the tr:document, isn't it?
> that would always invoke the func. I understood it like you 
> only want it sometimes.
> > Another thing is how can I store the JavaScript variable 
> 'lastFocusElem'? Of course, I can store it in my backing 
> bean...but I don't know if it is a good option.
> 
> Perhaps you want to use
> "TrPage.getInstance().sendPartialFormPost(.........)" for 
> doing the PPR postback:
> 
> /**
>  * Post the form for partial postback.  Supports both standard AJAX
>  * posts and, for multipart/form posts, IFRAME-based transmission.
>  * @param actionForm{FormElement} the HTML form to post
>  * @param params{Object} additional parameters to send
>  * @param headerParams{Object} HTTP headers to include (ignored if
>  *   the request must be a multipart/form post)
>  */
>   TrPage.getInstance().sendPartialFormPost(
>      theForm,
>      {param1: "value1", param2: "value2"},
>      {header1: "headerValue1", header2: "headerValue2"});
> 
> 
> so, you can pass in some args.
> 
> -M
> 
> >
> >>
> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag 
> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale 
> > Lösungen 22. Oktober 2008 . Frankfurt am Main
> >
> > _______________________________
> > Think before you print
> > CONFIDENTIALITY: This e-mail (including any attachments) 
> may contain confidential, proprietary and privileged 
> information, and unauthorized disclosure or use is 
> prohibited.  If you receive this e-mail in error, please 
> notify the sender and delete this e-mail from your system.
> >
> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister 
> > Frankfurt HRB 56839  Geschäftsführer Harold Finders, 
> Thorsten Junike, 
> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >
> > -----Ursprüngliche Nachricht-----
> >> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] 
> Im Auftrag 
> >> von Matthias Wessendorf
> >> Gesendet: Mittwoch, 13. August 2008 12:46
> >> An: MyFaces Discussion
> >> Betreff: Re: [Trinidad] set focus after partial submit
> >>
> >> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
> >>
> >> you even can "add" the function (to do the element.focus) 
> dynamically.
> >>
> >> -M
> >>
> >> >
> >> >
> >> > at the very end of the (ajax) response a <script> tag is added,
> >> >
> >> > like
> >> >
> >> > <script id....>doSomeNiceStuff(....)</script>
> >> >
> >> > this should work
> >> >>
> >> >> Regards,
> >> >>
> >> >> Sven
> >> >>
> >> >>>
> >> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . 
> www.sungard.de/finanztag 
> >> >> Complexity, Compliance & Cost: Globale Herausforderungen
> >> und lokale
> >> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
> >> >>
> >> >> _______________________________
> >> >> Think before you print
> >> >> CONFIDENTIALITY: This e-mail (including any attachments)
> >> may contain confidential, proprietary and privileged 
> information, and 
> >> unauthorized disclosure or use is prohibited.  If you receive this 
> >> e-mail in error, please notify the sender and delete this 
> e-mail from 
> >> your system.
> >> >>
> >> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
> >> Handelsregister
> >> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
> >> Thorsten Junike,
> >> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >> >>
> >> >> -----Ursprüngliche Nachricht-----
> >> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
> >> Im Auftrag
> >> >>> von Matthias Wessendorf
> >> >>> Gesendet: Mittwoch, 13. August 2008 11:34
> >> >>> An: MyFaces Discussion
> >> >>> Betreff: Re: [Trinidad] set focus after partial submit
> >> >>>
> >> >>> Sven,
> >> >>>
> >> >>> we have a dom-update-listener. From the Trinidad 
> DevGuide ([1]).
> >> >>>
> >> >>> Trinidad also lets you get notified when DOM is 
> replaced after an 
> >> >>> AJAX response by adding a "DOM replace listener" on the page:
> >> >>>
> >> >>>     function myCallback(oldDom, newDom) { ... }
> >> >>>
> >> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
> >> >>>
> >> >>> The callback is passed two parameters: the old DOM
> >> element and the
> >> >>> new DOM element that is replacing it. This callback is
> >> invoked after
> >> >>> the replacement has happened. As with 
> addStateChangeListener(), a 
> >> >>> second argument can be passed if you need a "this" to be
> >> active when
> >> >>> your callback is notified.
> >> >>>
> >> >>>
> >> >>> So, when the ppr was handled by the Trinidad client
> >> engine and the
> >> >>> dom is replaced. you could "search" for an element, and call 
> >> >>> "element.focus()".
> >> >>> Can you try that ?
> >> >>>
> >> >>> -Matthias
> >> >>>
> >> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
> >> >>>
> >> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven 
> >> >>> <Sv...@sungard.de> wrote:
> >> >>> > I think I have figured out my issue but I don't know how I
> >> >>> can fix it.
> >> >>> > The problem is the action method. It returns an existing
> >> >>> navigation-rule so that the page is completely refreshed
> >> after the
> >> >>> partial submit is done. This is necessary because the
> >> table could be
> >> >>> changed (regarding of the column count).
> >> >>> >
> >> >>> > Regards,
> >> >>> >
> >> >>> > Sven
> >> >>> >
> >> >>> >>
> >> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >> www.sungard.de/finanztag
> >> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und 
> >> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
> >> >>> >
> >> >>> > _______________________________ Think before you print
> >> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
> >> >>> may contain confidential, proprietary and privileged 
> information, 
> >> >>> and unauthorized disclosure or use is prohibited.  If 
> you receive 
> >> >>> this e-mail in error, please notify the sender and delete this 
> >> >>> e-mail from your system.
> >> >>> >
> >> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main, 
> >> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold 
> >> >>> > Finders,
> >> >>> Thorsten Junike,
> >> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria 
> Elizabeth Silbey
> >> >>> >
> >> >>> > -----Ursprüngliche Nachricht-----
> >> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
> >> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
> >> >>> >> An: MyFaces Discussion
> >> >>> >> Betreff: [Trinidad] set focus after partial submit
> >> >>> >>
> >> >>> >> Hi,
> >> >>> >>
> >> >>> >> i have the following JavaScript code that should execute a 
> >> >>> >> partial submit. After the response is completed the
> >> focus should
> >> >>> >> be set on the input element that have triggered the request.
> >> >>> >>
> >> >>> >> <tr:inputText label="#{bundle.searchPattern}"
> >> >>> >>   value="#{myBean.searchPattern}"
> >> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn, 
> this);" />
> >> >>> >>
> >> >>> >> <tr:commandButton id="submitSearch"
> >> >>> action="#{myBean.executeSearch}"
> >> >>> >>   text="#{bundle.search}" partialSubmit="true" />
> >> >>> >>
> >> >>> >> <tr:table partialTriggers="submitSearch"
> >> >>> value="#{myBean.tableData}">
> >> >>> >>   <!-- my columns goes here --> </tr:table>
> >> >>> >>
> >> >>> >> <script type="text/javascript" language="javascript">
> >> >>> >>   // <![CDATA[
> >> >>> >>     var submitBtn =
> >> window.document.getElementById("submitSearch");
> >> >>> >>     var lastFocusElem = null;
> >> >>> >>
> >> >>> >>     function setFocus(state)
> >> >>> >>     {
> >> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
> >> >>> >>       {
> >> >>> >>         if(lastFocusElem != null)
> >> >>> >>         {
> >> >>> >>           lastFocusElem.focus();
> >> >>> >>           lastFocusElem = null;
> >> >>> >>         }
> >> >>> >>
> >> >>> >> 
> TrPage.getInstance().getRequestQueue().removeStateChangeListen
> >> >>> >> er(setFocu
> >> >>> >> s);
> >> >>> >>       }
> >> >>> >>     }
> >> >>> >>
> >> >>> >>     function clickButton_afterEnter(evt, button, source)
> >> >>> >>     {
> >> >>> >>       evt = (evt) ? evt : (window.event) ? 
> window.event : "";
> >> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
> >> >>> >> evt.keyCode
> >> >>> >> : window.event.keyCode;
> >> >>> >>       if(keycode == 13)
> >> >>> >>       {
> >> >>> >>         var btn = (button == null) ? submitBtn : button;
> >> >>> >>         var form = document.forms[0];
> >> >>> >>         if(btn != null && form != null)
> >> >>> >>         {
> >> >>> >>           lastFocusElem = source;
> >> >>> >>
> >> >>> >> 
> TrPage.getInstance().getRequestQueue().addStateChangeListener(
> >> >>> >> setFocus);
> >> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
> >> >>> >>         }
> >> >>> >>       }
> >> >>> >>     }
> >> >>> >>   // ]]>
> >> >>> >> </script>
> >> >>> >>
> >> >>> >> Unfortunately the focus is lost from the input 
> field if I have 
> >> >>> >> pressed the enter key and the response was completed.
> >> >>> >> Does anybody have an idea what is going wrong here?
> >> >>> >>
> >> >>> >> Regards,
> >> >>> >>
> >> >>> >> Sven
> >> >>> >>
> >> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
> >> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
> >> >>> >> 2008 . Frankfurt am Main
> >> >>> >>
> >> >>> >> _______________________________ Think before you print
> >> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
> >> >>> may contain
> >> >>> >> confidential, proprietary and privileged information, and 
> >> >>> >> unauthorized disclosure or use is prohibited.  If 
> you receive 
> >> >>> >> this e-mail in error, please notify the sender and 
> delete this
> >> >>> e-mail from
> >> >>> >> your system.
> >> >>> >>
> >> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
> >> >>> Handelsregister
> >> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
> >> >>> Thorsten Junike,
> >> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria 
> Elizabeth Silbey
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Matthias Wessendorf
> >> >>>
> >> >>> Need JSF and Web 2.0?
> >> >>> http://code.google.com/p/facesgoodies
> >> >>>
> >> >>> further stuff:
> >> >>> blog: http://matthiaswessendorf.wordpress.com/
> >> >>> sessions: http://www.slideshare.net/mwessendorf
> >> >>> mail: matzew-at-apache-dot-org
> >> >>>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Matthias Wessendorf
> >> >
> >> > Need JSF and Web 2.0?
> >> > http://code.google.com/p/facesgoodies
> >> >
> >> > further stuff:
> >> > blog: http://matthiaswessendorf.wordpress.com/
> >> > sessions: http://www.slideshare.net/mwessendorf
> >> > mail: matzew-at-apache-dot-org
> >> >
> >>
> >>
> >>
> >> --
> >> Matthias Wessendorf
> >>
> >> Need JSF and Web 2.0?
> >> http://code.google.com/p/facesgoodies
> >>
> >> further stuff:
> >> blog: http://matthiaswessendorf.wordpress.com/
> >> sessions: http://www.slideshare.net/mwessendorf
> >> mail: matzew-at-apache-dot-org
> >>
> >
> >
> 
> 
> 
> --
> Matthias Wessendorf
> 
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
> 
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
> 


Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
On Wed, Aug 13, 2008 at 1:01 PM, Rottstock, Sven
<Sv...@sungard.de> wrote:
> Ok - I can test it. But it should be the same when I add an "onload" attribute to the tr:document, isn't it?
that would always invoke the func. I understood it like you only want
it sometimes.
> Another thing is how can I store the JavaScript variable 'lastFocusElem'? Of course, I can store it in my backing bean...but I don't know if it is a good option.

Perhaps you want to use
"TrPage.getInstance().sendPartialFormPost(.........)" for doing the
PPR postback:

/**
 * Post the form for partial postback.  Supports both standard AJAX
 * posts and, for multipart/form posts, IFRAME-based transmission.
 * @param actionForm{FormElement} the HTML form to post
 * @param params{Object} additional parameters to send
 * @param headerParams{Object} HTTP headers to include (ignored if
 *   the request must be a multipart/form post)
 */
  TrPage.getInstance().sendPartialFormPost(
     theForm,
     {param1: "value1", param2: "value2"},
     {header1: "headerValue1", header2: "headerValue2"});


so, you can pass in some args.

-M

>
>>
> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
> 22. Oktober 2008 . Frankfurt am Main
>
> _______________________________
> Think before you print
> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>
> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>
> -----Ursprüngliche Nachricht-----
>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>> Auftrag von Matthias Wessendorf
>> Gesendet: Mittwoch, 13. August 2008 12:46
>> An: MyFaces Discussion
>> Betreff: Re: [Trinidad] set focus after partial submit
>>
>> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
>>
>> you even can "add" the function (to do the element.focus) dynamically.
>>
>> -M
>>
>> >
>> >
>> > at the very end of the (ajax) response a <script> tag is added,
>> >
>> > like
>> >
>> > <script id....>doSomeNiceStuff(....)</script>
>> >
>> > this should work
>> >>
>> >> Regards,
>> >>
>> >> Sven
>> >>
>> >>>
>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>> >> Complexity, Compliance & Cost: Globale Herausforderungen
>> und lokale
>> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >>
>> >> _______________________________
>> >> Think before you print
>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>> may contain confidential, proprietary and privileged
>> information, and unauthorized disclosure or use is
>> prohibited.  If you receive this e-mail in error, please
>> notify the sender and delete this e-mail from your system.
>> >>
>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> Handelsregister
>> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>> Thorsten Junike,
>> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >>
>> >> -----Ursprüngliche Nachricht-----
>> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com]
>> Im Auftrag
>> >>> von Matthias Wessendorf
>> >>> Gesendet: Mittwoch, 13. August 2008 11:34
>> >>> An: MyFaces Discussion
>> >>> Betreff: Re: [Trinidad] set focus after partial submit
>> >>>
>> >>> Sven,
>> >>>
>> >>> we have a dom-update-listener. From the Trinidad DevGuide ([1]).
>> >>>
>> >>> Trinidad also lets you get notified when DOM is replaced after an
>> >>> AJAX response by adding a "DOM replace listener" on the page:
>> >>>
>> >>>     function myCallback(oldDom, newDom) { ... }
>> >>>
>> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>> >>>
>> >>> The callback is passed two parameters: the old DOM
>> element and the
>> >>> new DOM element that is replacing it. This callback is
>> invoked after
>> >>> the replacement has happened. As with addStateChangeListener(), a
>> >>> second argument can be passed if you need a "this" to be
>> active when
>> >>> your callback is notified.
>> >>>
>> >>>
>> >>> So, when the ppr was handled by the Trinidad client
>> engine and the
>> >>> dom is replaced. you could "search" for an element, and call
>> >>> "element.focus()".
>> >>> Can you try that ?
>> >>>
>> >>> -Matthias
>> >>>
>> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>> >>>
>> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>> >>> <Sv...@sungard.de> wrote:
>> >>> > I think I have figured out my issue but I don't know how I
>> >>> can fix it.
>> >>> > The problem is the action method. It returns an existing
>> >>> navigation-rule so that the page is completely refreshed
>> after the
>> >>> partial submit is done. This is necessary because the
>> table could be
>> >>> changed (regarding of the column count).
>> >>> >
>> >>> > Regards,
>> >>> >
>> >>> > Sven
>> >>> >
>> >>> >>
>> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> www.sungard.de/finanztag
>> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und
>> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >>> >
>> >>> > _______________________________
>> >>> > Think before you print
>> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
>> >>> may contain confidential, proprietary and privileged information,
>> >>> and unauthorized disclosure or use is prohibited.  If you receive
>> >>> this e-mail in error, please notify the sender and delete this
>> >>> e-mail from your system.
>> >>> >
>> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main,
>> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold
>> >>> > Finders,
>> >>> Thorsten Junike,
>> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >>> >
>> >>> > -----Ursprüngliche Nachricht-----
>> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>> >>> >> An: MyFaces Discussion
>> >>> >> Betreff: [Trinidad] set focus after partial submit
>> >>> >>
>> >>> >> Hi,
>> >>> >>
>> >>> >> i have the following JavaScript code that should execute a
>> >>> >> partial submit. After the response is completed the
>> focus should
>> >>> >> be set on the input element that have triggered the request.
>> >>> >>
>> >>> >> <tr:inputText label="#{bundle.searchPattern}"
>> >>> >>   value="#{myBean.searchPattern}"
>> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
>> >>> >>
>> >>> >> <tr:commandButton id="submitSearch"
>> >>> action="#{myBean.executeSearch}"
>> >>> >>   text="#{bundle.search}" partialSubmit="true" />
>> >>> >>
>> >>> >> <tr:table partialTriggers="submitSearch"
>> >>> value="#{myBean.tableData}">
>> >>> >>   <!-- my columns goes here -->
>> >>> >> </tr:table>
>> >>> >>
>> >>> >> <script type="text/javascript" language="javascript">
>> >>> >>   // <![CDATA[
>> >>> >>     var submitBtn =
>> window.document.getElementById("submitSearch");
>> >>> >>     var lastFocusElem = null;
>> >>> >>
>> >>> >>     function setFocus(state)
>> >>> >>     {
>> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
>> >>> >>       {
>> >>> >>         if(lastFocusElem != null)
>> >>> >>         {
>> >>> >>           lastFocusElem.focus();
>> >>> >>           lastFocusElem = null;
>> >>> >>         }
>> >>> >>
>> >>> >> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>> >>> >> er(setFocu
>> >>> >> s);
>> >>> >>       }
>> >>> >>     }
>> >>> >>
>> >>> >>     function clickButton_afterEnter(evt, button, source)
>> >>> >>     {
>> >>> >>       evt = (evt) ? evt : (window.event) ? window.event : "";
>> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>> >>> >> evt.keyCode
>> >>> >> : window.event.keyCode;
>> >>> >>       if(keycode == 13)
>> >>> >>       {
>> >>> >>         var btn = (button == null) ? submitBtn : button;
>> >>> >>         var form = document.forms[0];
>> >>> >>         if(btn != null && form != null)
>> >>> >>         {
>> >>> >>           lastFocusElem = source;
>> >>> >>
>> >>> >> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>> >>> >> setFocus);
>> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>> >>> >>         }
>> >>> >>       }
>> >>> >>     }
>> >>> >>   // ]]>
>> >>> >> </script>
>> >>> >>
>> >>> >> Unfortunately the focus is lost from the input field if I have
>> >>> >> pressed the enter key and the response was completed.
>> >>> >> Does anybody have an idea what is going wrong here?
>> >>> >>
>> >>> >> Regards,
>> >>> >>
>> >>> >> Sven
>> >>> >>
>> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>> >>> >> 2008 . Frankfurt am Main
>> >>> >>
>> >>> >> _______________________________
>> >>> >> Think before you print
>> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>> >>> may contain
>> >>> >> confidential, proprietary and privileged information, and
>> >>> >> unauthorized disclosure or use is prohibited.  If you receive
>> >>> >> this e-mail in error, please notify the sender and delete this
>> >>> e-mail from
>> >>> >> your system.
>> >>> >>
>> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> >>> Handelsregister
>> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>> >>> Thorsten Junike,
>> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Matthias Wessendorf
>> >>>
>> >>> Need JSF and Web 2.0?
>> >>> http://code.google.com/p/facesgoodies
>> >>>
>> >>> further stuff:
>> >>> blog: http://matthiaswessendorf.wordpress.com/
>> >>> sessions: http://www.slideshare.net/mwessendorf
>> >>> mail: matzew-at-apache-dot-org
>> >>>
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Matthias Wessendorf
>> >
>> > Need JSF and Web 2.0?
>> > http://code.google.com/p/facesgoodies
>> >
>> > further stuff:
>> > blog: http://matthiaswessendorf.wordpress.com/
>> > sessions: http://www.slideshare.net/mwessendorf
>> > mail: matzew-at-apache-dot-org
>> >
>>
>>
>>
>> --
>> Matthias Wessendorf
>>
>> Need JSF and Web 2.0?
>> http://code.google.com/p/facesgoodies
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
>
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

AW: [Trinidad] set focus after partial submit

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Ok - I can test it. But it should be the same when I add an "onload" attribute to the tr:document, isn't it?
Another thing is how can I store the JavaScript variable 'lastFocusElem'? Of course, I can store it in my backing bean...but I don't know if it is a good option.

> 
JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey

-----Ursprüngliche Nachricht-----
> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im 
> Auftrag von Matthias Wessendorf
> Gesendet: Mittwoch, 13. August 2008 12:46
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] set focus after partial submit
> 
> > erks.addScript(facesContext, "doSomeNiceStuff(....)");
> 
> you even can "add" the function (to do the element.focus) dynamically.
> 
> -M
> 
> >
> >
> > at the very end of the (ajax) response a <script> tag is added,
> >
> > like
> >
> > <script id....>doSomeNiceStuff(....)</script>
> >
> > this should work
> >>
> >> Regards,
> >>
> >> Sven
> >>
> >>>
> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag 
> >> Complexity, Compliance & Cost: Globale Herausforderungen 
> und lokale 
> >> Lösungen 22. Oktober 2008 . Frankfurt am Main
> >>
> >> _______________________________
> >> Think before you print
> >> CONFIDENTIALITY: This e-mail (including any attachments) 
> may contain confidential, proprietary and privileged 
> information, and unauthorized disclosure or use is 
> prohibited.  If you receive this e-mail in error, please 
> notify the sender and delete this e-mail from your system.
> >>
> >> SunGard Systeme GmbH  Registered Frankfurt am Main, 
> Handelsregister 
> >> Frankfurt HRB 56839  Geschäftsführer Harold Finders, 
> Thorsten Junike, 
> >> Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >>
> >> -----Ursprüngliche Nachricht-----
> >>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] 
> Im Auftrag 
> >>> von Matthias Wessendorf
> >>> Gesendet: Mittwoch, 13. August 2008 11:34
> >>> An: MyFaces Discussion
> >>> Betreff: Re: [Trinidad] set focus after partial submit
> >>>
> >>> Sven,
> >>>
> >>> we have a dom-update-listener. From the Trinidad DevGuide ([1]).
> >>>
> >>> Trinidad also lets you get notified when DOM is replaced after an 
> >>> AJAX response by adding a "DOM replace listener" on the page:
> >>>
> >>>     function myCallback(oldDom, newDom) { ... }
> >>>
> >>>     TrPage.getInstance().addDomReplaceListener(myCallback);
> >>>
> >>> The callback is passed two parameters: the old DOM 
> element and the 
> >>> new DOM element that is replacing it. This callback is 
> invoked after 
> >>> the replacement has happened. As with addStateChangeListener(), a 
> >>> second argument can be passed if you need a "this" to be 
> active when 
> >>> your callback is notified.
> >>>
> >>>
> >>> So, when the ppr was handled by the Trinidad client 
> engine and the 
> >>> dom is replaced. you could "search" for an element, and call 
> >>> "element.focus()".
> >>> Can you try that ?
> >>>
> >>> -Matthias
> >>>
> >>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
> >>>
> >>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven 
> >>> <Sv...@sungard.de> wrote:
> >>> > I think I have figured out my issue but I don't know how I
> >>> can fix it.
> >>> > The problem is the action method. It returns an existing
> >>> navigation-rule so that the page is completely refreshed 
> after the 
> >>> partial submit is done. This is necessary because the 
> table could be 
> >>> changed (regarding of the column count).
> >>> >
> >>> > Regards,
> >>> >
> >>> > Sven
> >>> >
> >>> >>
> >>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . 
> www.sungard.de/finanztag 
> >>> > Complexity, Compliance & Cost: Globale Herausforderungen und 
> >>> > lokale Lösungen 22. Oktober 2008 . Frankfurt am Main
> >>> >
> >>> > _______________________________
> >>> > Think before you print
> >>> > CONFIDENTIALITY: This e-mail (including any attachments)
> >>> may contain confidential, proprietary and privileged information, 
> >>> and unauthorized disclosure or use is prohibited.  If you receive 
> >>> this e-mail in error, please notify the sender and delete this 
> >>> e-mail from your system.
> >>> >
> >>> > SunGard Systeme GmbH  Registered Frankfurt am Main, 
> >>> > Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold 
> >>> > Finders,
> >>> Thorsten Junike,
> >>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >>> >
> >>> > -----Ursprüngliche Nachricht-----
> >>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
> >>> >> Gesendet: Mittwoch, 13. August 2008 10:26
> >>> >> An: MyFaces Discussion
> >>> >> Betreff: [Trinidad] set focus after partial submit
> >>> >>
> >>> >> Hi,
> >>> >>
> >>> >> i have the following JavaScript code that should execute a 
> >>> >> partial submit. After the response is completed the 
> focus should 
> >>> >> be set on the input element that have triggered the request.
> >>> >>
> >>> >> <tr:inputText label="#{bundle.searchPattern}"
> >>> >>   value="#{myBean.searchPattern}"
> >>> >>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
> >>> >>
> >>> >> <tr:commandButton id="submitSearch"
> >>> action="#{myBean.executeSearch}"
> >>> >>   text="#{bundle.search}" partialSubmit="true" />
> >>> >>
> >>> >> <tr:table partialTriggers="submitSearch"
> >>> value="#{myBean.tableData}">
> >>> >>   <!-- my columns goes here -->
> >>> >> </tr:table>
> >>> >>
> >>> >> <script type="text/javascript" language="javascript">
> >>> >>   // <![CDATA[
> >>> >>     var submitBtn = 
> window.document.getElementById("submitSearch");
> >>> >>     var lastFocusElem = null;
> >>> >>
> >>> >>     function setFocus(state)
> >>> >>     {
> >>> >>       if(state != TrRequestQueue.STATE_BUSY)
> >>> >>       {
> >>> >>         if(lastFocusElem != null)
> >>> >>         {
> >>> >>           lastFocusElem.focus();
> >>> >>           lastFocusElem = null;
> >>> >>         }
> >>> >>
> >>> >> TrPage.getInstance().getRequestQueue().removeStateChangeListen
> >>> >> er(setFocu
> >>> >> s);
> >>> >>       }
> >>> >>     }
> >>> >>
> >>> >>     function clickButton_afterEnter(evt, button, source)
> >>> >>     {
> >>> >>       evt = (evt) ? evt : (window.event) ? window.event : "";
> >>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
> >>> >> evt.keyCode
> >>> >> : window.event.keyCode;
> >>> >>       if(keycode == 13)
> >>> >>       {
> >>> >>         var btn = (button == null) ? submitBtn : button;
> >>> >>         var form = document.forms[0];
> >>> >>         if(btn != null && form != null)
> >>> >>         {
> >>> >>           lastFocusElem = source;
> >>> >>
> >>> >> TrPage.getInstance().getRequestQueue().addStateChangeListener(
> >>> >> setFocus);
> >>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
> >>> >>         }
> >>> >>       }
> >>> >>     }
> >>> >>   // ]]>
> >>> >> </script>
> >>> >>
> >>> >> Unfortunately the focus is lost from the input field if I have 
> >>> >> pressed the enter key and the response was completed.
> >>> >> Does anybody have an idea what is going wrong here?
> >>> >>
> >>> >> Regards,
> >>> >>
> >>> >> Sven
> >>> >>
> >>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
> >>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
> >>> >> 2008 . Frankfurt am Main
> >>> >>
> >>> >> _______________________________
> >>> >> Think before you print
> >>> >> CONFIDENTIALITY: This e-mail (including any attachments)
> >>> may contain
> >>> >> confidential, proprietary and privileged information, and 
> >>> >> unauthorized disclosure or use is prohibited.  If you receive 
> >>> >> this e-mail in error, please notify the sender and delete this
> >>> e-mail from
> >>> >> your system.
> >>> >>
> >>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
> >>> Handelsregister
> >>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
> >>> Thorsten Junike,
> >>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >>> >>
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Matthias Wessendorf
> >>>
> >>> Need JSF and Web 2.0?
> >>> http://code.google.com/p/facesgoodies
> >>>
> >>> further stuff:
> >>> blog: http://matthiaswessendorf.wordpress.com/
> >>> sessions: http://www.slideshare.net/mwessendorf
> >>> mail: matzew-at-apache-dot-org
> >>>
> >>
> >>
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > Need JSF and Web 2.0?
> > http://code.google.com/p/facesgoodies
> >
> > further stuff:
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > mail: matzew-at-apache-dot-org
> >
> 
> 
> 
> --
> Matthias Wessendorf
> 
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
> 
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
> 


Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
> erks.addScript(facesContext, "doSomeNiceStuff(....)");

you even can "add" the function (to do the element.focus)
dynamically.

-M

>
>
> at the very end of the (ajax) response a <script> tag is added,
>
> like
>
> <script id....>doSomeNiceStuff(....)</script>
>
> this should work
>>
>> Regards,
>>
>> Sven
>>
>>>
>> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
>> 22. Oktober 2008 . Frankfurt am Main
>>
>> _______________________________
>> Think before you print
>> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>>
>> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>
>> -----Ursprüngliche Nachricht-----
>>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>>> Auftrag von Matthias Wessendorf
>>> Gesendet: Mittwoch, 13. August 2008 11:34
>>> An: MyFaces Discussion
>>> Betreff: Re: [Trinidad] set focus after partial submit
>>>
>>> Sven,
>>>
>>> we have a dom-update-listener. From the Trinidad DevGuide ([1]).
>>>
>>> Trinidad also lets you get notified when DOM is replaced
>>> after an AJAX response by adding a "DOM replace listener" on the page:
>>>
>>>     function myCallback(oldDom, newDom) { ... }
>>>
>>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>>>
>>> The callback is passed two parameters: the old DOM element
>>> and the new DOM element that is replacing it. This callback
>>> is invoked after the replacement has happened. As with
>>> addStateChangeListener(), a second argument can be passed if
>>> you need a "this" to be active when your callback is notified.
>>>
>>>
>>> So, when the ppr was handled by the Trinidad client engine
>>> and the dom is replaced. you could "search" for an element,
>>> and call "element.focus()".
>>> Can you try that ?
>>>
>>> -Matthias
>>>
>>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>>>
>>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>>> <Sv...@sungard.de> wrote:
>>> > I think I have figured out my issue but I don't know how I
>>> can fix it.
>>> > The problem is the action method. It returns an existing
>>> navigation-rule so that the page is completely refreshed
>>> after the partial submit is done. This is necessary because
>>> the table could be changed (regarding of the column count).
>>> >
>>> > Regards,
>>> >
>>> > Sven
>>> >
>>> >>
>>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>>> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale
>>> > Lösungen 22. Oktober 2008 . Frankfurt am Main
>>> >
>>> > _______________________________
>>> > Think before you print
>>> > CONFIDENTIALITY: This e-mail (including any attachments)
>>> may contain confidential, proprietary and privileged
>>> information, and unauthorized disclosure or use is
>>> prohibited.  If you receive this e-mail in error, please
>>> notify the sender and delete this e-mail from your system.
>>> >
>>> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister
>>> > Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>>> Thorsten Junike,
>>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>> >
>>> > -----Ursprüngliche Nachricht-----
>>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>>> >> An: MyFaces Discussion
>>> >> Betreff: [Trinidad] set focus after partial submit
>>> >>
>>> >> Hi,
>>> >>
>>> >> i have the following JavaScript code that should execute a partial
>>> >> submit. After the response is completed the focus should be set on
>>> >> the input element that have triggered the request.
>>> >>
>>> >> <tr:inputText label="#{bundle.searchPattern}"
>>> >>   value="#{myBean.searchPattern}"
>>> >>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
>>> >>
>>> >> <tr:commandButton id="submitSearch"
>>> action="#{myBean.executeSearch}"
>>> >>   text="#{bundle.search}" partialSubmit="true" />
>>> >>
>>> >> <tr:table partialTriggers="submitSearch"
>>> value="#{myBean.tableData}">
>>> >>   <!-- my columns goes here -->
>>> >> </tr:table>
>>> >>
>>> >> <script type="text/javascript" language="javascript">
>>> >>   // <![CDATA[
>>> >>     var submitBtn = window.document.getElementById("submitSearch");
>>> >>     var lastFocusElem = null;
>>> >>
>>> >>     function setFocus(state)
>>> >>     {
>>> >>       if(state != TrRequestQueue.STATE_BUSY)
>>> >>       {
>>> >>         if(lastFocusElem != null)
>>> >>         {
>>> >>           lastFocusElem.focus();
>>> >>           lastFocusElem = null;
>>> >>         }
>>> >>
>>> >> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>>> >> er(setFocu
>>> >> s);
>>> >>       }
>>> >>     }
>>> >>
>>> >>     function clickButton_afterEnter(evt, button, source)
>>> >>     {
>>> >>       evt = (evt) ? evt : (window.event) ? window.event : "";
>>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>>> >> evt.keyCode
>>> >> : window.event.keyCode;
>>> >>       if(keycode == 13)
>>> >>       {
>>> >>         var btn = (button == null) ? submitBtn : button;
>>> >>         var form = document.forms[0];
>>> >>         if(btn != null && form != null)
>>> >>         {
>>> >>           lastFocusElem = source;
>>> >>
>>> >> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>>> >> setFocus);
>>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>>> >>         }
>>> >>       }
>>> >>     }
>>> >>   // ]]>
>>> >> </script>
>>> >>
>>> >> Unfortunately the focus is lost from the input field if I have
>>> >> pressed the enter key and the response was completed.
>>> >> Does anybody have an idea what is going wrong here?
>>> >>
>>> >> Regards,
>>> >>
>>> >> Sven
>>> >>
>>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>>> >> 2008 . Frankfurt am Main
>>> >>
>>> >> _______________________________
>>> >> Think before you print
>>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>>> may contain
>>> >> confidential, proprietary and privileged information, and
>>> >> unauthorized disclosure or use is prohibited.  If you receive this
>>> >> e-mail in error, please notify the sender and delete this
>>> e-mail from
>>> >> your system.
>>> >>
>>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>>> Handelsregister
>>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>>> Thorsten Junike,
>>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>>> >>
>>> >>
>>> >>
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Matthias Wessendorf
>>>
>>> Need JSF and Web 2.0?
>>> http://code.google.com/p/facesgoodies
>>>
>>> further stuff:
>>> blog: http://matthiaswessendorf.wordpress.com/
>>> sessions: http://www.slideshare.net/mwessendorf
>>> mail: matzew-at-apache-dot-org
>>>
>>
>>
>
>
>
> --
> Matthias Wessendorf
>
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
On Wed, Aug 13, 2008 at 12:16 PM, Rottstock, Sven
<Sv...@sungard.de> wrote:
> Hi Matthias,
>
> thank you for your answer. I have tried to add the DOM replacement listener but it wasn't invoked in my case. It seems to be a difference between a simple partial submit and a partial submit with a resulting refresh of the page (because of the navigation rule). I have also added a tr:selectManyListbox with autoSubmit="true". When I click on an item of the listbox the DOM replacment listener is invoked. So theoretically it should work...

ok, another thing you may try:

provide a JS function in your page, like

function doSomeNiceStuff(...);

and in the action method do this:


    ExtendedRenderKitService erks = Service
      .getRenderKitService(facesContext, ExtendedRenderKitService.class);


erks.addScript(facesContext, "doSomeNiceStuff(....)");


at the very end of the (ajax) response a <script> tag is added,

like

<script id....>doSomeNiceStuff(....)</script>

this should work
>
> Regards,
>
> Sven
>
>>
> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
> 22. Oktober 2008 . Frankfurt am Main
>
> _______________________________
> Think before you print
> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>
> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>
> -----Ursprüngliche Nachricht-----
>> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im
>> Auftrag von Matthias Wessendorf
>> Gesendet: Mittwoch, 13. August 2008 11:34
>> An: MyFaces Discussion
>> Betreff: Re: [Trinidad] set focus after partial submit
>>
>> Sven,
>>
>> we have a dom-update-listener. From the Trinidad DevGuide ([1]).
>>
>> Trinidad also lets you get notified when DOM is replaced
>> after an AJAX response by adding a "DOM replace listener" on the page:
>>
>>     function myCallback(oldDom, newDom) { ... }
>>
>>     TrPage.getInstance().addDomReplaceListener(myCallback);
>>
>> The callback is passed two parameters: the old DOM element
>> and the new DOM element that is replacing it. This callback
>> is invoked after the replacement has happened. As with
>> addStateChangeListener(), a second argument can be passed if
>> you need a "this" to be active when your callback is notified.
>>
>>
>> So, when the ppr was handled by the Trinidad client engine
>> and the dom is replaced. you could "search" for an element,
>> and call "element.focus()".
>> Can you try that ?
>>
>> -Matthias
>>
>> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
>>
>> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
>> <Sv...@sungard.de> wrote:
>> > I think I have figured out my issue but I don't know how I
>> can fix it.
>> > The problem is the action method. It returns an existing
>> navigation-rule so that the page is completely refreshed
>> after the partial submit is done. This is necessary because
>> the table could be changed (regarding of the column count).
>> >
>> > Regards,
>> >
>> > Sven
>> >
>> >>
>> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
>> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale
>> > Lösungen 22. Oktober 2008 . Frankfurt am Main
>> >
>> > _______________________________
>> > Think before you print
>> > CONFIDENTIALITY: This e-mail (including any attachments)
>> may contain confidential, proprietary and privileged
>> information, and unauthorized disclosure or use is
>> prohibited.  If you receive this e-mail in error, please
>> notify the sender and delete this e-mail from your system.
>> >
>> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister
>> > Frankfurt HRB 56839  Geschäftsführer Harold Finders,
>> Thorsten Junike,
>> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >
>> > -----Ursprüngliche Nachricht-----
>> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>> >> Gesendet: Mittwoch, 13. August 2008 10:26
>> >> An: MyFaces Discussion
>> >> Betreff: [Trinidad] set focus after partial submit
>> >>
>> >> Hi,
>> >>
>> >> i have the following JavaScript code that should execute a partial
>> >> submit. After the response is completed the focus should be set on
>> >> the input element that have triggered the request.
>> >>
>> >> <tr:inputText label="#{bundle.searchPattern}"
>> >>   value="#{myBean.searchPattern}"
>> >>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
>> >>
>> >> <tr:commandButton id="submitSearch"
>> action="#{myBean.executeSearch}"
>> >>   text="#{bundle.search}" partialSubmit="true" />
>> >>
>> >> <tr:table partialTriggers="submitSearch"
>> value="#{myBean.tableData}">
>> >>   <!-- my columns goes here -->
>> >> </tr:table>
>> >>
>> >> <script type="text/javascript" language="javascript">
>> >>   // <![CDATA[
>> >>     var submitBtn = window.document.getElementById("submitSearch");
>> >>     var lastFocusElem = null;
>> >>
>> >>     function setFocus(state)
>> >>     {
>> >>       if(state != TrRequestQueue.STATE_BUSY)
>> >>       {
>> >>         if(lastFocusElem != null)
>> >>         {
>> >>           lastFocusElem.focus();
>> >>           lastFocusElem = null;
>> >>         }
>> >>
>> >> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>> >> er(setFocu
>> >> s);
>> >>       }
>> >>     }
>> >>
>> >>     function clickButton_afterEnter(evt, button, source)
>> >>     {
>> >>       evt = (evt) ? evt : (window.event) ? window.event : "";
>> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>> >> evt.keyCode
>> >> : window.event.keyCode;
>> >>       if(keycode == 13)
>> >>       {
>> >>         var btn = (button == null) ? submitBtn : button;
>> >>         var form = document.forms[0];
>> >>         if(btn != null && form != null)
>> >>         {
>> >>           lastFocusElem = source;
>> >>
>> >> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>> >> setFocus);
>> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>> >>         }
>> >>       }
>> >>     }
>> >>   // ]]>
>> >> </script>
>> >>
>> >> Unfortunately the focus is lost from the input field if I have
>> >> pressed the enter key and the response was completed.
>> >> Does anybody have an idea what is going wrong here?
>> >>
>> >> Regards,
>> >>
>> >> Sven
>> >>
>> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
>> >> Globale Herausforderungen und lokale Losungen 22. Oktober
>> >> 2008 . Frankfurt am Main
>> >>
>> >> _______________________________
>> >> Think before you print
>> >> CONFIDENTIALITY: This e-mail (including any attachments)
>> may contain
>> >> confidential, proprietary and privileged information, and
>> >> unauthorized disclosure or use is prohibited.  If you receive this
>> >> e-mail in error, please notify the sender and delete this
>> e-mail from
>> >> your system.
>> >>
>> >> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> Handelsregister
>> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders,
>> Thorsten Junike,
>> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>
>> --
>> Matthias Wessendorf
>>
>> Need JSF and Web 2.0?
>> http://code.google.com/p/facesgoodies
>>
>> further stuff:
>> blog: http://matthiaswessendorf.wordpress.com/
>> sessions: http://www.slideshare.net/mwessendorf
>> mail: matzew-at-apache-dot-org
>>
>
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

AW: [Trinidad] set focus after partial submit

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
Hi Matthias,

thank you for your answer. I have tried to add the DOM replacement listener but it wasn't invoked in my case. It seems to be a difference between a simple partial submit and a partial submit with a resulting refresh of the page (because of the navigation rule). I have also added a tr:selectManyListbox with autoSubmit="true". When I click on an item of the listbox the DOM replacment listener is invoked. So theoretically it should work...

Regards,

Sven 

> 
JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey

-----Ursprüngliche Nachricht-----
> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im 
> Auftrag von Matthias Wessendorf
> Gesendet: Mittwoch, 13. August 2008 11:34
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] set focus after partial submit
> 
> Sven,
> 
> we have a dom-update-listener. From the Trinidad DevGuide ([1]).
> 
> Trinidad also lets you get notified when DOM is replaced 
> after an AJAX response by adding a "DOM replace listener" on the page:
> 
>     function myCallback(oldDom, newDom) { ... }
> 
>     TrPage.getInstance().addDomReplaceListener(myCallback);
> 
> The callback is passed two parameters: the old DOM element 
> and the new DOM element that is replacing it. This callback 
> is invoked after the replacement has happened. As with 
> addStateChangeListener(), a second argument can be passed if 
> you need a "this" to be active when your callback is notified.
> 
> 
> So, when the ppr was handled by the Trinidad client engine 
> and the dom is replaced. you could "search" for an element, 
> and call "element.focus()".
> Can you try that ?
> 
> -Matthias
> 
> [1] http://myfaces.apache.org/trinidad/devguide/ppr.html
> 
> On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven 
> <Sv...@sungard.de> wrote:
> > I think I have figured out my issue but I don't know how I 
> can fix it.
> > The problem is the action method. It returns an existing 
> navigation-rule so that the page is completely refreshed 
> after the partial submit is done. This is necessary because 
> the table could be changed (regarding of the column count).
> >
> > Regards,
> >
> > Sven
> >
> >>
> > JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag 
> > Complexity, Compliance & Cost: Globale Herausforderungen und lokale 
> > Lösungen 22. Oktober 2008 . Frankfurt am Main
> >
> > _______________________________
> > Think before you print
> > CONFIDENTIALITY: This e-mail (including any attachments) 
> may contain confidential, proprietary and privileged 
> information, and unauthorized disclosure or use is 
> prohibited.  If you receive this e-mail in error, please 
> notify the sender and delete this e-mail from your system.
> >
> > SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister 
> > Frankfurt HRB 56839  Geschäftsführer Harold Finders, 
> Thorsten Junike, 
> > Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >
> > -----Ursprüngliche Nachricht-----
> >> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
> >> Gesendet: Mittwoch, 13. August 2008 10:26
> >> An: MyFaces Discussion
> >> Betreff: [Trinidad] set focus after partial submit
> >>
> >> Hi,
> >>
> >> i have the following JavaScript code that should execute a partial 
> >> submit. After the response is completed the focus should be set on 
> >> the input element that have triggered the request.
> >>
> >> <tr:inputText label="#{bundle.searchPattern}"
> >>   value="#{myBean.searchPattern}"
> >>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
> >>
> >> <tr:commandButton id="submitSearch" 
> action="#{myBean.executeSearch}"
> >>   text="#{bundle.search}" partialSubmit="true" />
> >>
> >> <tr:table partialTriggers="submitSearch" 
> value="#{myBean.tableData}">
> >>   <!-- my columns goes here -->
> >> </tr:table>
> >>
> >> <script type="text/javascript" language="javascript">
> >>   // <![CDATA[
> >>     var submitBtn = window.document.getElementById("submitSearch");
> >>     var lastFocusElem = null;
> >>
> >>     function setFocus(state)
> >>     {
> >>       if(state != TrRequestQueue.STATE_BUSY)
> >>       {
> >>         if(lastFocusElem != null)
> >>         {
> >>           lastFocusElem.focus();
> >>           lastFocusElem = null;
> >>         }
> >>
> >> TrPage.getInstance().getRequestQueue().removeStateChangeListen
> >> er(setFocu
> >> s);
> >>       }
> >>     }
> >>
> >>     function clickButton_afterEnter(evt, button, source)
> >>     {
> >>       evt = (evt) ? evt : (window.event) ? window.event : "";
> >>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
> >> evt.keyCode
> >> : window.event.keyCode;
> >>       if(keycode == 13)
> >>       {
> >>         var btn = (button == null) ? submitBtn : button;
> >>         var form = document.forms[0];
> >>         if(btn != null && form != null)
> >>         {
> >>           lastFocusElem = source;
> >>
> >> TrPage.getInstance().getRequestQueue().addStateChangeListener(
> >> setFocus);
> >>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
> >>         }
> >>       }
> >>     }
> >>   // ]]>
> >> </script>
> >>
> >> Unfortunately the focus is lost from the input field if I have 
> >> pressed the enter key and the response was completed.
> >> Does anybody have an idea what is going wrong here?
> >>
> >> Regards,
> >>
> >> Sven
> >>
> >> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
> >> www.sungard.de/finanztag Complexity, Compliance & Cost:
> >> Globale Herausforderungen und lokale Losungen 22. Oktober
> >> 2008 . Frankfurt am Main
> >>
> >> _______________________________
> >> Think before you print
> >> CONFIDENTIALITY: This e-mail (including any attachments) 
> may contain 
> >> confidential, proprietary and privileged information, and 
> >> unauthorized disclosure or use is prohibited.  If you receive this 
> >> e-mail in error, please notify the sender and delete this 
> e-mail from 
> >> your system.
> >>
> >> SunGard Systeme GmbH  Registered Frankfurt am Main, 
> Handelsregister 
> >> Frankfurt HRB 56839  Geschaftsfuhrer Harold Finders, 
> Thorsten Junike, 
> >> Dr. Dirk Luth, Michael Joseph Ruane, Victoria Elizabeth Silbey
> >>
> >>
> >>
> >
> >
> 
> 
> 
> --
> Matthias Wessendorf
> 
> Need JSF and Web 2.0?
> http://code.google.com/p/facesgoodies
> 
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> mail: matzew-at-apache-dot-org
> 


Re: [Trinidad] set focus after partial submit

Posted by Matthias Wessendorf <ma...@apache.org>.
Sven,

we have a dom-update-listener. From the Trinidad DevGuide ([1]).

Trinidad also lets you get notified when DOM is replaced after an AJAX
response by adding a "DOM replace listener" on the page:

    function myCallback(oldDom, newDom) { ... }

    TrPage.getInstance().addDomReplaceListener(myCallback);

The callback is passed two parameters: the old DOM element and the new
DOM element that is replacing it. This callback is invoked after the
replacement has happened. As with addStateChangeListener(), a second
argument can be passed if you need a "this" to be active when your
callback is notified.


So, when the ppr was handled by the Trinidad client engine and the dom
is replaced. you could "search" for an element, and call
"element.focus()".
Can you try that ?

-Matthias

[1] http://myfaces.apache.org/trinidad/devguide/ppr.html

On Wed, Aug 13, 2008 at 11:28 AM, Rottstock, Sven
<Sv...@sungard.de> wrote:
> I think I have figured out my issue but I don't know how I can fix it.
> The problem is the action method. It returns an existing navigation-rule so that the page is completely refreshed after the partial submit is done. This is necessary because the table could be changed (regarding of the column count).
>
> Regards,
>
> Sven
>
>>
> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
> Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
> 22. Oktober 2008 . Frankfurt am Main
>
> _______________________________
> Think before you print
> CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.
>
> SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey
>
> -----Ursprüngliche Nachricht-----
>> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de]
>> Gesendet: Mittwoch, 13. August 2008 10:26
>> An: MyFaces Discussion
>> Betreff: [Trinidad] set focus after partial submit
>>
>> Hi,
>>
>> i have the following JavaScript code that should execute a
>> partial submit. After the response is completed the focus
>> should be set on the input element that have triggered the request.
>>
>> <tr:inputText label="#{bundle.searchPattern}"
>>   value="#{myBean.searchPattern}"
>>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
>>
>> <tr:commandButton id="submitSearch" action="#{myBean.executeSearch}"
>>   text="#{bundle.search}" partialSubmit="true" />
>>
>> <tr:table partialTriggers="submitSearch" value="#{myBean.tableData}">
>>   <!-- my columns goes here -->
>> </tr:table>
>>
>> <script type="text/javascript" language="javascript">
>>   // <![CDATA[
>>     var submitBtn = window.document.getElementById("submitSearch");
>>     var lastFocusElem = null;
>>
>>     function setFocus(state)
>>     {
>>       if(state != TrRequestQueue.STATE_BUSY)
>>       {
>>         if(lastFocusElem != null)
>>         {
>>           lastFocusElem.focus();
>>           lastFocusElem = null;
>>         }
>>
>> TrPage.getInstance().getRequestQueue().removeStateChangeListen
>> er(setFocu
>> s);
>>       }
>>     }
>>
>>     function clickButton_afterEnter(evt, button, source)
>>     {
>>       evt = (evt) ? evt : (window.event) ? window.event : "";
>>       var keycode = evt.which ? evt.which : (evt.keyCode) ?
>> evt.keyCode
>> : window.event.keyCode;
>>       if(keycode == 13)
>>       {
>>         var btn = (button == null) ? submitBtn : button;
>>         var form = document.forms[0];
>>         if(btn != null && form != null)
>>         {
>>           lastFocusElem = source;
>>
>> TrPage.getInstance().getRequestQueue().addStateChangeListener(
>> setFocus);
>>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>>         }
>>       }
>>     }
>>   // ]]>
>> </script>
>>
>> Unfortunately the focus is lost from the input field if I
>> have pressed the enter key and the response was completed.
>> Does anybody have an idea what is going wrong here?
>>
>> Regards,
>>
>> Sven
>>
>> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 .
>> www.sungard.de/finanztag Complexity, Compliance & Cost:
>> Globale Herausforderungen und lokale Losungen 22. Oktober
>> 2008 . Frankfurt am Main
>>
>> _______________________________
>> Think before you print
>> CONFIDENTIALITY: This e-mail (including any attachments) may
>> contain confidential, proprietary and privileged information,
>> and unauthorized disclosure or use is prohibited.  If you
>> receive this e-mail in error, please notify the sender and
>> delete this e-mail from your system.
>>
>> SunGard Systeme GmbH  Registered Frankfurt am Main,
>> Handelsregister Frankfurt HRB 56839  Geschaftsfuhrer Harold
>> Finders, Thorsten Junike, Dr. Dirk Luth, Michael Joseph
>> Ruane, Victoria Elizabeth Silbey
>>
>>
>>
>
>



-- 
Matthias Wessendorf

Need JSF and Web 2.0?
http://code.google.com/p/facesgoodies

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
mail: matzew-at-apache-dot-org

AW: [Trinidad] set focus after partial submit

Posted by "Rottstock, Sven" <Sv...@sungard.de>.
I think I have figured out my issue but I don't know how I can fix it. 
The problem is the action method. It returns an existing navigation-rule so that the page is completely refreshed after the partial submit is done. This is necessary because the table could be changed (regarding of the column count).

Regards,

Sven

> 
JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . www.sungard.de/finanztag
Complexity, Compliance & Cost: Globale Herausforderungen und lokale Lösungen
22. Oktober 2008 . Frankfurt am Main 

_______________________________
Think before you print
CONFIDENTIALITY: This e-mail (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited.  If you receive this e-mail in error, please notify the sender and delete this e-mail from your system.

SunGard Systeme GmbH  Registered Frankfurt am Main, Handelsregister Frankfurt HRB 56839  Geschäftsführer Harold Finders, Thorsten Junike, Dr. Dirk Lüth, Michael Joseph Ruane, Victoria Elizabeth Silbey

-----Ursprüngliche Nachricht-----
> Von: Rottstock, Sven [mailto:Sven.Rottstock@sungard.de] 
> Gesendet: Mittwoch, 13. August 2008 10:26
> An: MyFaces Discussion
> Betreff: [Trinidad] set focus after partial submit
> 
> Hi,
> 
> i have the following JavaScript code that should execute a 
> partial submit. After the response is completed the focus 
> should be set on the input element that have triggered the request.
> 
> <tr:inputText label="#{bundle.searchPattern}"
>   value="#{myBean.searchPattern}"
>   onkeyup="clickButton_afterEnter(event, submitBtn, this);" />
> 
> <tr:commandButton id="submitSearch" action="#{myBean.executeSearch}"
>   text="#{bundle.search}" partialSubmit="true" />
> 
> <tr:table partialTriggers="submitSearch" value="#{myBean.tableData}">
>   <!-- my columns goes here -->
> </tr:table>
> 
> <script type="text/javascript" language="javascript">
>   // <![CDATA[
>     var submitBtn = window.document.getElementById("submitSearch");
>     var lastFocusElem = null;
>                                 
>     function setFocus(state)
>     {
>       if(state != TrRequestQueue.STATE_BUSY)
>       {
>         if(lastFocusElem != null)
>         {
>           lastFocusElem.focus();
>           lastFocusElem = null;
>         }
>  
> TrPage.getInstance().getRequestQueue().removeStateChangeListen
> er(setFocu
> s);
>       }
>     }
>                                 
>     function clickButton_afterEnter(evt, button, source)
>     {
>       evt = (evt) ? evt : (window.event) ? window.event : "";
>       var keycode = evt.which ? evt.which : (evt.keyCode) ? 
> evt.keyCode
> : window.event.keyCode;
>       if(keycode == 13)
>       {
>         var btn = (button == null) ? submitBtn : button;
>         var form = document.forms[0];
>         if(btn != null && form != null)
>         {
>           lastFocusElem = source;
>  
> TrPage.getInstance().getRequestQueue().addStateChangeListener(
> setFocus);
>           TrPage._autoSubmit(form.id, btn.id, evt, true, 0);
>         }
>       }
>     }
>   // ]]>
> </script>
> 
> Unfortunately the focus is lost from the input field if I 
> have pressed the enter key and the response was completed.
> Does anybody have an idea what is going wrong here?
> 
> Regards,
> 
> Sven
> 
> JETZT ANMELDEN: SunGard FINANZ-TAG 2008 . 
> www.sungard.de/finanztag Complexity, Compliance & Cost: 
> Globale Herausforderungen und lokale Losungen 22. Oktober 
> 2008 . Frankfurt am Main 
> 
> _______________________________
> Think before you print
> CONFIDENTIALITY: This e-mail (including any attachments) may 
> contain confidential, proprietary and privileged information, 
> and unauthorized disclosure or use is prohibited.  If you 
> receive this e-mail in error, please notify the sender and 
> delete this e-mail from your system.
> 
> SunGard Systeme GmbH  Registered Frankfurt am Main, 
> Handelsregister Frankfurt HRB 56839  Geschaftsfuhrer Harold 
> Finders, Thorsten Junike, Dr. Dirk Luth, Michael Joseph 
> Ruane, Victoria Elizabeth Silbey
> 
> 
>