composite-component

Programmatically create and add composite component in backing bean

北城余情 提交于 2019-11-27 08:09:17
I am working with a dynamic dashboard where users can pin and remove items as they like. Now I have a problem that I want to add existing composite component to the view from the backing bean. I've tried to find correct way to do this from the internet but no success so far. Here is the simple composite component I want to add: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:cc="http://java.sun.com/jsf/composite" xmlns:ui="http:/

How to programmatically or dynamically create a composite component in JSF 2

笑着哭i 提交于 2019-11-27 07:20:27
I need to programatically create composite components in JSF 2. After few days of searching and experiments I figure out this method (higly inspired by Lexi at java.net): /** * Method will attach composite component to provided component * @param viewPanel parent component of newly created composite component */ public void setComponentJ(UIComponent viewPanel) { FacesContext context = FacesContext.getCurrentInstance(); viewPanel.getChildren().clear(); // load composite component from file Resource componentResource = context.getApplication().getResourceHandler().createResource("whatever.xhtml"

Pass Argument to a composite-component action attribute

好久不见. 提交于 2019-11-27 07:01:24
The title really says it all. I have made an attempt which failed with the error: Illegal attempt to pass arguments to a composite component lookup expression (i.e. cc.attrs.[identifier]). My attempt looks like this: <composite:interface> <composite:attribute name="removeFieldAction" method-signature="void action(java.lang.String)" /> </composite:interface> <composite:implementation> <h:commandButton value="Remove" action="#{cc.attrs.removeFieldAction('SomeString')}"/> </composite:implementation> What's the right way to do this? This is indeed not going to work. You cannot pass "extra"

How to make same JSF Composite Component included multiple times to have its own javascript scope?

半腔热情 提交于 2019-11-27 04:54:12
问题 I have a JSF composite component like this: <cc:implementation> <div id="#{cc.clientId}"> <h:outputScript library="js" name="helper.js"/> <script type="text/javascript"> if(typeof variables === "undefined"){ var variables = {}; } (function(){ variables.formid = '#{cc.clientId}'; })(); </script> </div> Value of variables.formid I'm using in a helper.js file. When I include this composite component only once, it's working like it should. When I include multiple composite components, every

How to create a composite component for a datatable column?

扶醉桌前 提交于 2019-11-27 01:10:54
Given this datatable (naturally working): <rich:dataTable var="var" value="#{values}"> <rich:column> <f:facet name="header"> HEADER </f:facet> <h:outputText value="#{var}" /> </rich:column> </rich:dataTable> If I define a custom component (also ok in the syntax and at the right place under resources/components): <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns

Rerendering composite component by ajax

与世无争的帅哥 提交于 2019-11-26 23:20:16
问题 I have build a composite component witch looks something like this: <composite:interface> <composite:attribute name="id" required="false" /> <composite:attribute name="label" required="true" /> </composite:interface> <composite:implementation> <h:panelGroup id="#{cc.attrs.id}"> <fieldset class="fieldset"><legend>${cc.attrs.label}</legend></fieldset> </h:panelGroup> </composite:implementation> The compent displays the current label correctly. <xyz:comp id="idMyComponent" label="#{someBean.text

How to save state when extending UIComponentBase

江枫思渺然 提交于 2019-11-26 22:56:20
I'm creating a composite component that will wrap a datatable to implement very simple paging. I need to save state (the current page number) between ajax requests. I tried creating fields in my FacesComponent, but I discovered they are wiped out during the JSF lifecycle: @FacesComponent(value = "bfTableComponent") public class BFTableComponent extends UIComponentBase implements NamingContainer { private int currentPageNumber; ... I can't seems to find a concise guide to doing this anywhere! How would one save state between requests when creating a composite component? Use StateHelper . It's

Referring composite component ID in f:ajax render

自闭症网瘾萝莉.ら 提交于 2019-11-26 22:25:50
问题 I am writing a composite component that is intended to wrap an input element, and augment it with an 'optional field' designation and h:message element below it. Here is the component (in input.xhtml file): <composite:interface/> <composite:implementation> <div> #{component.children[1].setStyleClass(component.children[1].valid ? '' : 'inputError')} <composite:insertChildren/> </div> <h:panelGroup styleClass="optional" rendered="#{!component.parent.children[1].required}" layout="block" > #

How to specify a validator for an input component inside a composite component?

只谈情不闲聊 提交于 2019-11-26 21:26:59
问题 Should I register a custom validator in faces-config.xml if I'm using JSF 2.0.4? My custom validator uses Validator interface which is javax.faces.validator.Validator . <cc:myComp id="customcomp1" ... /> <cc:myComp id="customcomp2" ...> <f:validator id="myvalidator" for="myComp" /> </cc:myComp> myComp.xhtml <cc:interface> <cc:attribute ... /> <!-- more attributes --> </cc:interface> <cc:implementation> <h:panelGroup layout="block"> <h:inputText id="firstName" ... /> <h:inputText id=

JSF 2 - How can I add an Ajax listener method to composite component interface?

冷暖自知 提交于 2019-11-26 19:36:47
问题 I have a JSF 2 composite component that employs some Ajax behavior. I want to add a listener method to the <f:ajax> tag inside my composite component, but the listener method should be provided as a <composite:attribute> in the <composite:interface> . The <f:ajax> tag inside my composite component is currently hard-coded to a listener like this: <f:ajax event="valueChange" execute="@this" listener="#{controller.genericAjaxEventLogger}" render="#{cc.attrs.ajaxRenderTargets}" /> The listener