Hi Dieter,

the onclick attribue of tc:command does not work (is not implemented). I tried 
the same thing as you before.

See http://issues.apache.org/jira/browse/TOBAGO-272

Maybe it will be implemented if there's more than one request for it.

As a workaround you can do the disabling on the server with ajax. Use the 
renderedpartially attribute of
tc:command and reload the input fields every time the checkbox is clicked.

Regards
Helmut

  ----- Original Message ----- 
  From: Melnizky Dieter 
  To: users@myfaces.apache.org 
  Sent: Wednesday, June 13, 2007 3:40 PM
  Subject: [Tobago] Using tc:command with client side JavaScript


  I want to toggle the disabled attribute of input fields, depending on the 
selected value of a tc:selectBooleanCheckbox.
  The idea is to add a JavaScript function that enables the fields, which 
should be called when the selectBooleanCheckbox is clicked.
  Since the onchange-Attribute is not supported, I tried to use a change facet 
with a tc:command, setting the onclick attribute to the function I wrote:

  ...
  ...
  <tc:script>

  function immediateChanged() {
   var immediate = 
Tobago.element("page:ft_download_parameter:immediateCheckBox").checked == true;
   // change fields here ...
  }
  </tc:script>

  ...
  <tc:selectBooleanCheckbox value="#{getData.immediate}" id="immediateCheckBox" 
label="#{nbmBundle.ft_labelImmediate}" tip="#{nbmBundle.ft_tipImmediate}">
   <f:facet name="change">
    <tc:command immediate="false" onclick="immediateChanged();"></tc:command>
   </f:facet>
  </tc:selectBooleanCheckbox>

  This is generated, my immediateChanged() function is ignored (the complete 
page is submitted to the server):

  var element = Tobago.element("page:ft_download_parameter:immediateCheckBox");
  if (element) {
  Tobago.addEventListener(element, "change", 
function(){Tobago.submitAction('page:ft_download_parameter:_idJsp92')});
  }

  Does anyone have an idea how I can call my client side JavaScript function, 
when the user has clicked the checkbox?

  Best regards,
  Dieter
  The information contained in this e-mail message is privileged and
  confidential and is for the exclusive use of the addressee. The person
  who receives this message and who is not the addressee, one of his
  employees or an agent entitled to hand it over to the addressee, is
  informed that he may not use, disclose or reproduce the contents thereof.


Reply via email to