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 <[EMAIL PROTECTED]>:
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 <[EMAIL PROTECTED]>:
> 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

Reply via email to