Search code examples
javajqueryjsfrichfaces

JSF / Richfaces - How to set HtmlJQuery dynamically in the page


I'm adding a mask into a field in my ManagedBean.

                htmlJQuery = new HtmlJQuery();
                htmlJQuery.setSelector("#"+perguntaVO.getCodigo() + (sequence == null ? "" : "_" + sequence));
                htmlJQuery.setQuery("mask('999.999.999-99')");
                htmlJQuery.setTiming("onload");
                htmlGroup.getChildren().add(htmlJQuery);

But this new mask is not evaluated in the page. It is only evaluated if I submit the page.

What I need to do to have this jquery evaluated dynamically ?


Solution

  • There is no need to use richfaces Jquery object in this case.

    This line did the trick:

    input.setOnfocus("$('"+"#form\\\\:"+componentID+"').mask('999.999.999-99').change();");