Pass method argument/parameter to composite-component action attribute

This is indeed not going to work. You cannot pass “extra” parameters afterwards like that. The method-signature as you have declared has to be fulfilled in the side where the composite component is been used. E.g. <my:button action=”#{bean.remove(‘Somestring’)}” /> The composite component implementation should just look like this <h:commandButton value=”Remove” action=”#{cc.attrs.removeFieldAction}” /> If this is … Read more

Initialize a composite component based on the provided attributes

As to the cause, UIComponent instances are inherently request scoped. The postback effectively creates a brand new instance with properties like values reinitialized to default. In your implementation, it is only filled during encodeXxx(), which is invoked long after decode() wherein the action event needs to be queued and thus too late. You’d better fill … Read more

How to save state when extending UIComponentBase

Use StateHelper. It’s available by UIComponent#getStateHelper(). private enum PropertyKeys { currentPageNumber; } public void setCurrentPageNumber(int currentPageNumber) { getStateHelper().put(PropertyKeys.currentPageNumber, currentPageNumber); } public int getCurrentPageNumber() { return (int) getStateHelper().eval(PropertyKeys.currentPageNumber, 0); } Note that I’m returning a default value of 0 in the getter. You might want to change int to Integer and remove the default value so … Read more

How to create a composite component for a datatable column?

The <my:mycolumn> element must be an instance of UIColumn as that’s the only valid child of a UIData component during the render response phase. All other UIComponent types will be ignored, thus not rendered. A composite component is implicitly a UINamingContaner component, which isn’t a UIColumn and therefore ignored. A PrimeFaces <p:dataTable> with a backing … Read more

How to implement a dynamic list with a JSF 2.0 Composite Component?

I’d use a <h:dataTable> in a composite component with a backing UIComponent which you can bind by componentType attribute of the <composite:interface>. In the backing UIComponent you can then maintain the DataModel and define the actions. dynamicFieldList.xhtml <ui:composition xmlns:f=”http://java.sun.com/jsf/core” xmlns:h=”http://java.sun.com/jsf/html” xmlns:ui=”http://java.sun.com/jsf/facelets” xmlns:cc=”http://java.sun.com/jsf/composite” > <cc:interface componentType=”dynamicFieldList”> <cc:attribute name=”value” type=”java.util.List” required=”true” /> </cc:interface> <cc:implementation> <h:dataTable id=”table” binding=”#{cc.table}” … Read more

When to use , tag files, composite components and/or custom components?

What is the difference between those approaches? Facelet templates Use Facelet templates (as in <ui:composition>, <ui:include> and <ui:decorate>) if you want to split main page layout fragments into reuseable templates. E.g. header, menu, content, footer, etc. Examples: How to include another XHTML in XHTML using JSF 2.0 Facelets? What is the real conceptual difference between … Read more