This is my code:
1,
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
<ui:composition>
<cc:interface>
<cc:attribute name="id" />
<cc:attribute name="action" targets="remote" />
</cc:interface>
<cc:implementation>
<p:remoteCommand id="remote" name="remoteCommand" />
<input onclick="remoteCommand();" />
</cc:implementation>
</ui:composition>
</h:body>
</html>
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:mycomponent="http://java.sun.com/jsf/composite/composites">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="styles" name="ownContainers.css" />
</h:head>
<h:body>
<h:form>
<mycomponent:input action="#{testBean.test()}" />
<mycomponent:input />
</h:form>
</h:body>
</html>
The previous code does not work! When I click on the first input field, my bean method is not executed.
However, when I include the action attribute also in the second input field, my bean method is executed:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:mycomponent="http://java.sun.com/jsf/composite/composites">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="styles" name="ownContainers.css" />
</h:head>
<h:body>
<h:form>
<mycomponent:input action="#{testBean.test()}" />
<mycomponent:input action="#{testBean.test()}" />
</h:form>
</h:body>
</html>