I am just trying to build a custom component with :
- firstly, a basic
onclick
javascript event on myp
tag rendered likealert("...")
- secondly, a server sider handling of the click event
.
// HelloComponent.java
@FacesComponent(createTag = true, tagName = "helloComponent", namespace = "http://example.com/tags")
public class HelloComponent extends UIComponentBase {
@Override
public String getFamily() {
return "Greeting";
}
@Override
public void encodeBegin(FacesContext context) throws IOException {
String message = (String) getAttributes().get("message");
ResponseWriter writer = context.getResponseWriter();
writer.startElement("p", this);
writer.write(message);
writer.endElement("p");
}
}
// index.xhtml (simplified)
<html ...>
<h:body>
<t:helloComponent message="Hello World !" />
</h:body>
</html>
I've been reading things about events/behaviors but I can not figure it out how it works.