2

I have a PrimeFaces checkbox on a JSF page that I'd like to check/uncheck using Javascript/jQuery. Looking at the PrimeFaces source code (forms.js) for SelectBooleanCheckbox.onclick:

 if(checked) {
    _self.output.removeClass('ui-state-active');
    _self.input.removeAttr('checked');
    _self.icon.removeClass('ui-icon ui-icon-check');
  } else {
    _self.output.addClass('ui-state-active');
    _self.input.attr('checked', 'checked');
    _self.icon.addClass('ui-icon ui-icon-check');
  }

Is there some Javascript API for PrimeFaces that will handle this for me or would I need to duplicate that code? I'm using PrimeFaces 3.0.M4.

2 Answers 2

3

Check out client side API sections in PrimeFaces user's guide. You can use widgetVar.check() and widgetVar.uncheck().

Sign up to request clarification or add additional context in comments.

1 Comment

Maybe I'm missing something, but I can't find those methods in the API or the user guide. The only methods available seem to be .enable() and .disable(). I'm using 3.0.M4 btw.
0

PrimeFaces renders unobstrusive javascript which cleanly seperates behavior from the html. Client side engine is powered by jQuery version 1.6.4. (That if you use 3.0.M4 - Primefaces 2 uses JQuery 1.4 if I remember correctly)

You can have access to the jquery library used by Primefaces using this code:

<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />

Also you should know that you mustn't use another jquery library! May cause instability!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.