You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madan Narra <ma...@gmail.com> on 2007/06/14 14:27:51 UTC

[Tobago] Multiple defaultCommands in the same Tobago Page

Hi All,

I have created a template which has a SideNavigation Bar with a textfield
and button, and the middle area has a textfield with a button next to it.

I set defaultCommand="true" for both the buttons, but only one works at a
time...

is it possible to set defaultCommand="true" for both the buttons, and submit
works to that button when the cursor focus  resides with its respecive
textfield.. ?

Can this be done... As i need this type of feature in my application
-- 
Regards,
Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Volker Weber <v....@inexso.de>.
Hi,

2007/6/15, Madan Narra <ma...@gmail.com>:
> Hi Volker,
>
> The change facet for <tc:in/> with renderedPartially set to the command has
> to call a feature via Ajax and display its result to the User in the same
> sheet.This Ajax request does not invoke any methods that interact with DB
>
> The defaultCommand functionality is used to update the List with the values
> set in <tc:in/> and update that in DB...
>
> so i would be needing both these features...

So you need both commands executed on enter?
Than you should rename the change facet to somthing undefined and add
a change eventListener in the init method.

>
> >if your sheet is loaded via ajax or has paging/sorting enabled you
> >must invoke the init function via tc:out escape=false.
> >Also the initial value for row needs  to passed to the init function then
>
> yes, the sheet is loaded via Ajax.. but how can do i invoke init function
> via <tc:out/> ?

<tc:out escape="false"
      value="<script type=\"text/javascript\">initOnEnter(...)</script>"/>


Regards,
    Volker

> I have used a new variable which gets iterated each time a new row is
> created and passed that to the init function.
>
> Is it possible to have this case satisfied ? or else i have to think for an
> other alternative..
>
> Thnx for ur reply
>
> Regards,
> Madan N
>

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Madan Narra <ma...@gmail.com>.
Hi Volker,

The change facet for <tc:in/> with renderedPartially set to the command has
to call a feature via Ajax and display its result to the User in the same
sheet.This Ajax request does not invoke any methods that interact with DB

The defaultCommand functionality is used to update the List with the values
set in <tc:in/> and update that in DB...

so i would be needing both these features...

>if your sheet is loaded via ajax or has paging/sorting enabled you
>must invoke the init function via tc:out escape=false.
>Also the initial value for row needs  to passed to the init function then

yes, the sheet is loaded via Ajax.. but how can do i invoke init function
via <tc:out/> ?
I have used a new variable which gets iterated each time a new row is
created and passed that to the init function.

Is it possible to have this case satisfied ? or else i have to think for an
other alternative..

Thnx for ur reply

Regards,
Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Volker Weber <v....@inexso.de>.
Hi,

2007/6/15, Madan Narra <ma...@gmail.com>:
> Hi Volker,
>
> But the <tc:in/> in the sheet has a change facet set to it with
> renderedPartially option...


why do you  need the defaultCommand functionality at the tc:in if you
already have a change facet? I don't think you will get an defined
behavior if you invoke both listeners via enter.

My 'command' facet did not influence the parallel 'change' facet,
'command' is not an official facet name and therefore not evaluated by
the renderer. You can use any not supported name fot this facet, it is
just to have a non rendered command component in the tree.

>
> Will the solution provided by you earlier be working ?
>
> I will try and see if there are any other issues occured and know u back...
>
> Thnx
>
> Regards,
> Madan N
>
>
>
> On 6/14/07, Volker Weber <v....@inexso.de> wrote:
> > Which version of tobago? Or what is in line 1199 in tobago.js?
> >
> > This solution is not compatible with input suggest, because there is
> > already a keyup handler.
> >
> > for the inputs in the sheet this could work, just the setup is more
> complicated.
> >
> > omit the "page:" in the init fuction call, but add the sheetId and
> > iterate the rows
> > e.g.
> >
> > function initOnEnter(sheetId, inputId, actionId) {
> >   var row = 0;
> >   var input = Tobago.element(sheetId + ":" + row + ":" + inputId);
> >   while (input) {
> >     input.actionId = actionId;
> >     Tobago.addEventListener(input, "keyup", "submitOnEnter(event)");
> >     row++;
> >     input = Tobago.element(sheetId + ":" + row + ":" + inputId);
> >   }
> > }
> >
> > change the submitAction part in the submitOnEnter function to
> >
> > if (keyCode == 13) {
> >    var input = Tobago.element(event);
> >    var idPrefix = input.id.substring(0, input.id.lastIndexOf(":") + 1);
> >    Tobago.submitAction(idPrefix +  input.actionId);
> > }
> >
> > if your sheet is loaded via ajax or has paging/sorting enabled you
> > must invoke the init function via tc:out escape=false.
> > Also the initial value for row needs  to passed to the init function then.
> >
> >
> > Regards,
> >    Volker
> >
> >
> >
> > 2007/6/14, Madan Narra <ma...@gmail.com>:
> > > Hi Volker ..
> > >
> > > Placed the same code as specified by you in previous mails...
> > >
> > > When working in FF with FireBug in it, saw this error
> > >
> > > uncaught exception: [Exception... "Could not convert JavaScript
> argument"
> > > nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"
> location: "JS frame ::
> > >
> http://localhost:8080/XXX/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
> > > :: anonymous :: line 1199"  data: no]
> > >
> > > Line 0
> > > And one more thing,
> > >
> > > The First Textbox has an inputSuggest feature and the seacond textbox as
> > > described in previous mail is a column in sheet with multiple textboxs
> and
> > > has an renderPartially set to it.
> > >
> > > Will your solution work for my case ?
> > >
> > > Regards,
> > > Madan N
> >
>
>
>
> --
> Regards,
> Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Madan Narra <ma...@gmail.com>.
Hi Volker,

But the <tc:in/> in the sheet has a change facet set to it with
renderedPartially option...

Will the solution provided by you earlier be working ?

I will try and see if there are any other issues occured and know u back...

Thnx

Regards,
Madan N


On 6/14/07, Volker Weber <v....@inexso.de> wrote:
>
> Which version of tobago? Or what is in line 1199 in tobago.js?
>
> This solution is not compatible with input suggest, because there is
> already a keyup handler.
>
> for the inputs in the sheet this could work, just the setup is more
> complicated.
>
> omit the "page:" in the init fuction call, but add the sheetId and
> iterate the rows
> e.g.
>
> function initOnEnter(sheetId, inputId, actionId) {
>   var row = 0;
>   var input = Tobago.element(sheetId + ":" + row + ":" + inputId);
>   while (input) {
>     input.actionId = actionId;
>     Tobago.addEventListener(input, "keyup", "submitOnEnter(event)");
>     row++;
>     input = Tobago.element(sheetId + ":" + row + ":" + inputId);
>   }
> }
>
> change the submitAction part in the submitOnEnter function to
>
> if (keyCode == 13) {
>    var input = Tobago.element(event);
>    var idPrefix = input.id.substring(0, input.id.lastIndexOf(":") + 1);
>    Tobago.submitAction(idPrefix +  input.actionId);
> }
>
> if your sheet is loaded via ajax or has paging/sorting enabled you
> must invoke the init function via tc:out escape=false.
> Also the initial value for row needs  to passed to the init function then.
>
>
> Regards,
>    Volker
>
>
>
> 2007/6/14, Madan Narra <ma...@gmail.com>:
> > Hi Volker ..
> >
> > Placed the same code as specified by you in previous mails...
> >
> > When working in FF with FireBug in it, saw this error
> >
> > uncaught exception: [Exception... "Could not convert JavaScript
> argument"
> > nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS
> frame ::
> >
> http://localhost:8080/XXX/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
> > :: anonymous :: line 1199"  data: no]
> >
> > Line 0
> > And one more thing,
> >
> > The First Textbox has an inputSuggest feature and the seacond textbox as
> > described in previous mail is a column in sheet with multiple textboxs
> and
> > has an renderPartially set to it.
> >
> > Will your solution work for my case ?
> >
> > Regards,
> > Madan N
>



-- 
Regards,
Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Volker Weber <v....@inexso.de>.
Which version of tobago? Or what is in line 1199 in tobago.js?

This solution is not compatible with input suggest, because there is
already a keyup handler.

for the inputs in the sheet this could work, just the setup is more complicated.

omit the "page:" in the init fuction call, but add the sheetId and
iterate the rows
e.g.

function initOnEnter(sheetId, inputId, actionId) {
   var row = 0;
   var input = Tobago.element(sheetId + ":" + row + ":" + inputId);
   while (input) {
     input.actionId = actionId;
     Tobago.addEventListener(input, "keyup", "submitOnEnter(event)");
     row++;
     input = Tobago.element(sheetId + ":" + row + ":" + inputId);
   }
}

change the submitAction part in the submitOnEnter function to

  if (keyCode == 13) {
    var input = Tobago.element(event);
    var idPrefix = input.id.substring(0, input.id.lastIndexOf(":") + 1);
    Tobago.submitAction(idPrefix +  input.actionId);
  }

if your sheet is loaded via ajax or has paging/sorting enabled you
must invoke the init function via tc:out escape=false.
Also the initial value for row needs  to passed to the init function then.


Regards,
    Volker



2007/6/14, Madan Narra <ma...@gmail.com>:
> Hi Volker ..
>
> Placed the same code as specified by you in previous mails...
>
> When working in FF with FireBug in it, saw this error
>
> uncaught exception: [Exception... "Could not convert JavaScript argument"
> nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame ::
> http://localhost:8080/XXX/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
> :: anonymous :: line 1199"  data: no]
>
> Line 0
> And one more thing,
>
> The First Textbox has an inputSuggest feature and the seacond textbox as
> described in previous mail is a column in sheet with multiple textboxs and
> has an renderPartially set to it.
>
> Will your solution work for my case ?
>
> Regards,
> Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Madan Narra <ma...@gmail.com>.
Hi Volker ..

Placed the same code as specified by you in previous mails...

When working in FF with FireBug in it, saw this error

uncaught exception: [Exception... "Could not convert JavaScript argument"
nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame ::
http://localhost:8080/XXX/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js::
anonymous :: line 1199"  data: no]

Line 0
And one more thing,

The First Textbox has an inputSuggest feature and the seacond textbox as
described in previous mail is a column in sheet with multiple textboxs and
has an renderPartially set to it.

Will your solution work for my case ?

Regards,
Madan N

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Volker Weber <v....@inexso.de>.
Sorry i need to fix the javascript functions:

function initOnEnter(textId, actionId) {
   var input = Tobago.element(textId);
   if input) {
     input.actionId = actionId;
     Tobago.addEventListener(input, "keyup", "submitOnEnter(event)");
   }
 }
function submitOnEnter(event) {
   if (!event) {
     // IE
     event = window.event;
   }

  var keyCode;
    if (event.which) {
      keyCode = event.which;
    } else {
      keyCode = event.keyCode;
    }

   if (keyCode == 13) {
     Tobago.submitAction(Tobago.element(event).actionId);
   }
 }

2007/6/14, Volker Weber <v....@inexso.de>:
> Hi Madan,
>
> it is not possible to have mor than one defaultCommand.
>
> Can you use a 'change' facet?
>
> I think we need a 'enter' (and 'escape' ...) facet.
>
> Currently the only solution is to add a command facet and
> add a eventlistener to the input by javascript to invoke the command
> on keyup=13 event
> like this:
>
> <tc:script>
>   function initOnEnter(textId, actionId) {
>     var input = Tobago.element(textId);
>     if input) {
>       input.actionId = actionId;
>       Tobago.addEventListener(input, "keyup", "submitOnEnter(" + textId + ")");
>     }
>   }
>
>   function submitOnEnter(textId) {
>     Tobago.submitAction(Tobago.element(textId).actionId);
>   }
> </tc:script>
>
> <tc:in id="in_1" ...>
>   <f:facet name="command">
>     <tc:command id="cmd_1" .../>
>   </f:facet>
> </tc:in ...>
> <tc:script onload="initOnEnter('page:in_1', 'page:cmd_1')"/>
>
> note: this was just types from memory, but i have used something like
> this before.
> note2: tc:script (and tc:style) did not work on ajax requests e.g.
> partial rendering.
>           https://issues.apache.org/jira/browse/TOBAGO-332
>
> Hope this helps
>
> Regards,
>     Volker
>
>
>
> 2007/6/14, Madan Narra <ma...@gmail.com>:
> > Hi All,
> >
> > I have created a template which has a SideNavigation Bar with a textfield
> > and button, and the middle area has a textfield with a button next to it.
> >
> > I set defaultCommand="true" for both the buttons, but only one works at a
> > time...
> >
> > is it possible to set defaultCommand="true" for both the buttons, and submit
> > works to that button when the cursor focus  resides with its respecive
> > textfield.. ?
> >
> > Can this be done... As i need this type of feature in my application
> > --
> > Regards,
> > Madan N
>

Re: [Tobago] Multiple defaultCommands in the same Tobago Page

Posted by Volker Weber <v....@inexso.de>.
Hi Madan,

it is not possible to have mor than one defaultCommand.

Can you use a 'change' facet?

I think we need a 'enter' (and 'escape' ...) facet.

Currently the only solution is to add a command facet and
add a eventlistener to the input by javascript to invoke the command
on keyup=13 event
like this:

<tc:script>
  function initOnEnter(textId, actionId) {
    var input = Tobago.element(textId);
    if input) {
      input.actionId = actionId;
      Tobago.addEventListener(input, "keyup", "submitOnEnter(" + textId + ")");
    }
  }

  function submitOnEnter(textId) {
    Tobago.submitAction(Tobago.element(textId).actionId);
  }
</tc:script>

<tc:in id="in_1" ...>
  <f:facet name="command">
    <tc:command id="cmd_1" .../>
  </f:facet>
</tc:in ...>
<tc:script onload="initOnEnter('page:in_1', 'page:cmd_1')"/>

note: this was just types from memory, but i have used something like
this before.
note2: tc:script (and tc:style) did not work on ajax requests e.g.
partial rendering.
          https://issues.apache.org/jira/browse/TOBAGO-332

Hope this helps

Regards,
    Volker



2007/6/14, Madan Narra <ma...@gmail.com>:
> Hi All,
>
> I have created a template which has a SideNavigation Bar with a textfield
> and button, and the middle area has a textfield with a button next to it.
>
> I set defaultCommand="true" for both the buttons, but only one works at a
> time...
>
> is it possible to set defaultCommand="true" for both the buttons, and submit
> works to that button when the cursor focus  resides with its respecive
> textfield.. ?
>
> Can this be done... As i need this type of feature in my application
> --
> Regards,
> Madan N