You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by RICARD MORE FARRES <ri...@mango.com> on 2013/12/18 07:52:42 UTC

Adding ajax event to a DIV element

Hi,

I'm testing beta version of MyFaces 2.2 and I'm facing following problem. I just want to add an ajax call directly to a div element, as explained in last example of this page:

http://jsflive.wordpress.com/2013/08/08/jsf22-html5/#elements

The problem is that if I set the jsf:id to the div tag, I get this error message:

  *   Warning: The page /lab/div.jsp declares namespace null and uses the tag http://xmlns.jcp.org/jsf , but no TagLibrary associated to namespace.
And if I dont set the id there's no way to relate the render attribute of the ajax tag to the id. Here's the source code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
       <head jsf:id="head">
             <title>DIV 2.2</title>
       </head>
       <body jsf:id="body">
             <form jsf:id="form">
                    <div jsf:id="div1" style="width: 50px; height: 100px; background-color: blue;">
                           <span>#{bean.counter}</span>
                           <f:ajax event="click" render="@this" listener="#{bean.increment()}"/>
                    </div>
             </form>
       </body>
</html>

And if I set the render attribute of the ajax tag to "div1" I get another error, this time in the server side:
javax.faces.FacesException: Component with id:div1 not found

Any suggestion?
Ricard