Menu
  • HOME
  • TAGS

How do I pass an attribute from composite component to backing bean by using backing component?

jsf,jsf-2,composite-component

Based on your comments this is what you expect. Note that even if this implementation works, it is conceptually incorrect! You are considering from and to as INPUTS (not input components, but input values) and text as OUTPUT. This is not the way JSF is intended to work! However, here...

Preprocess/postprocess a bean action method from p:remoteCommand inside composite

jsf,jsf-2,primefaces,action,composite-component

This is indeed a little overcomplicated. In total 3 ajax requests to just perform an action and a backing component passing data forth and back via the view state. Your primary goal appears to be able to declare a bean action method as composite component attribute which should then be...

Override default validator of input in composite component

validation,jsf,jsf-2.2,composite-component

from your comment, I assume, you have a component like this: <cc:interface > <cc:editableValueHolder name="text" targets="myText" /> </cc:interface> <cc:implementation> <h:inputText id="myText"> <f:validateLength maximum="10" /> </h:inputText> </cc:implementation> And you want to use it - assuming its called myInput - like this: <ns:myInput> <f:validateLength maximum="5" for="text" /> </ns:myInput> hence, if no validateLength...

How can I load a resource bundle properties file within a composite component?

jsf,composite-component,resourcebundle,properties-file

Composites have implicit support for resource bundles via #{cc.resourceBundleMap}. This only prerequires: Bundle file is placed in same (sub)folder as composite XHTML itself. Bundle file has exactly the same filename (prefix) as composite XHTML itself. So, if you restructure a bit, WebContent |-- resources | `-- mylib | |-- mycomponent.css...

Adding composite component programmatically

jsf,composite-component,omnifaces

The includeCompositeComponent() returns an UIComponent instance representing the composite implementation. UIComponent composite = Components.includeCompositeComponent(someParentComponent, libraryName, resourceName, id); All of its attributes are available as a Map by UIComponent#getAttributes(). Map<String, Object> attributes = composite.getAttributes(); You can use Components#createMethodExpression() to create an EL method expression. Assuming that you intend to specify #{bean.complete},...

Execute a script on f:ajax “success” event only when validation has not failed

javascript,ajax,jsf-2,event-handling,composite-component

EL expressions are evaluated while generating HTML output. They are not evaluated during JavaScript events or so. Rightclick and View Source. You see, it's one and all HTML/JS. No JSF components, no EL expressions. JSF is "just" a HTML code generator. So when you load the page, #{facesContext.validationFailed} will print...

How to update an element with a certain ID [duplicate]

jsf,primefaces,composite-component

This can be really annoying, so in situations like this I usually target the components by style class. Try adding styleClass="orderList" to <p:orderList>, and target it with @(.orderList).

not working via

ajax,jsf-2.2,composite-component

Any relative client ID which is specified in <f:ajax render> is resolved relative to the parent ClientBehaviorHolder component in the component tree. In your particular case, this is actually the <h:selectOneRadio>. The component with client ID reg-unknown is thus being sought in the same naming container parent as the <h:selectOneRadio>,...

Execute javascript after composite component has been updated and rendered = “true”

jsf,jsf-2,composite-component

Add an inline <script> (or <h:outputScript>) to bottom of the conditionally rendered part of the composite which should execute the desired function. <cc:implementation> <ui:fragment rendered="#{someCondition}"> ... <script>someFunction();</script> </ui:fragment> </cc:implementation> That function can in turn delegate to $(document).ready(), if necessary....

How do I define a component as an attribute of composite component?

jsf,composite-component

You can bind your input component to an EL expression: <p:inputText widgetVar="asd" id="asd" binding="#{bindedAsd}" value="#{disciplineController.discipline.description}"/> This way you can use it as an attribute: <pe:keyboard textField="#{bindedAsd}" /> ...

How can I create a JSF composite component that allows me to read/write to the attributes?

jsf,composite-component

As I said, its pretty easy to get these variables with getAttributes() but I'm really not sure how to manipulate them. From the UIComponent#getAttributes() javadoc (emphasis mine): Return a mutable Map representing the attributes (and properties, see below) associated wth this UIComponent, keyed by attribute name (which must be...

Error when creating a DataScroller inside Composite Component

jsf,jsf-2,composite-component

To ensure reusability of multiple instances in the same view, composite components are inherently naming containers, like <h:form>, <h:dataTable>, etc. In your specific case, the relative client ID in for="myTable" will be searched in the context of <cc:implementation>, but there is no such component. Instead, it's outside the composite, in...

How can I cache data inside a composite component?

jsf,composite-component

Make use of the JSF view state as available by inherited getStateHelper() method. This basically acts like the JSF view scope. Make sure that you don't store/copy/duplicate whole model (the list) in the JSF view state, but only the indexes of added/removed items. See also: How to save state when...

Composite component with multiple input fields, validation failed in WebSphere 8.0

jsf,jsf-2,websphere,composite-component

First of all, WildFly doesn't use MyFaces. It uses Mojarra. As to your concrete problem, it turns out that in case of UIInput, MyFaces first processes the validation phase on the component's children and then finally the component itself, while Mojarra does exactly the other way round. Evidence can be...

NPE in AjaxHandler.applyAttachedObject when adding f:ajax to compositecomponent

ajax,jsf-2,jsf-2.2,composite-component

java.lang.NullPointerException at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.applyAttachedObject(AjaxHandler.java:333) Let's check the source of AjaxHandler#applyAttachedObject(): 332 Collection<String> eventNames = bHolder.getEventNames(); 333 if (!eventNames.contains(eventName)) { 334 throw new TagException(this.tag, 335 getUnsupportedEventMessage(eventName, eventNames, parent)); 336 } Aha, getEventNames() returned null. That method was implemented on UIComponentBase whose javadoc says the following: This is a default...

How to extend AjaxBehaviorEvent dispatched from @FacesComponent?

jsf,jsf-2,composite-component

Nice to meet you, again :) continuing from your previous question: Override queueEvent() to filter interesting events (changes from specific components) and postpone their enqueue to validation phase to be able to fetch converted & validated values: @FacesComponent("rangeComponent") public class RangeComponent extends UIInput implements NamingContainer { private final List<AjaxBehaviorEvent> customEvents...

Nested JSF Composite Components leading to a Stack Overflow exception

jsf,jstl,stack-overflow,composite-component,nesting

The problem was in the context of the #{cc} and the statefulness of the composite attribute. The #{cc} in any attribute of the nested composite references itself instead of the parent. The attribute being stateful means that the #{cc} was re-evaluated in every child which in turn ultimately references itself...

Ajax call to toggle a composite component boolean variable seems to work only once

ajax,jsf,render,composite-component

JSF components are created during view build time of every request. In other words, JSF component instances are basically request scoped. Your singleSelect property needs to be retained across postbacks on the same view. In other words, you want it to be view scoped. However, you assigned it as an...

Error: java.io.NotSerializableException: javax.faces.view.facelets.ValidatorHandler when validating composite component

validation,jsf,jsf-2,composite-component

Looks like just a bug in JSF implementation used. I am using the JSF implementation Mojarra 2.0.3-FCS This is almost 5 years old already (July 2010). It's currently already at 2.1.29 (July 2014). Or, as you're on a Servlet 3.0 compatible container anyway (Tomcat 7), go for latest 2.2.x, which...

Failing to set a default value to the composite component

jsf-2,jsf-2.2,composite-component

Digging deeper, I found some evidence of a bug, so I reported it. I'll update the answer to see if it is really a bug or some big misconception from me.

How to find an component ID including the composite component ID from backing bean

jsf,jsf-2,composite-component,clientid

"j_idt123" is a generated id for components which do not specify their own. Just give the parent-container of "tableForm" an id.

Receiving “old” value from Backing Component - correct usage of getValue, getLocalValue, getSubmittedValue

jsf,jsf-2,primefaces,composite-component

That article was edited after an user reported that it didn't work in MyFaces. The original getSubmittedValue() reads like: @Override public Object getSubmittedValue() { return day.getSubmittedValue() + "-" + month.getSubmittedValue() + "-" + year.getSubmittedValue(); } Then a MyFaces user reported this failed in MyFaces because it first processes the input's...

OmniFaces UnmappedResourceHandler seems to leak resources when composite components are used

jsf-2,memory-leaks,composite-component,omnifaces,unmappedresourcehandler

UnmappedResourceHandler memory leak on composite components is confirmed and has been solved by this commit for 2.1, this commit for 1.11 and this commit for 1.8.3. All versions are as of today available in Maven....

How to trigger Components#includeCompositeComponent() call?

jsf,composite-component,omnifaces

You need to trigger it during the view build time. The postAddToView event listener approach must work. Perhaps you did it the wrong way. Here's a kickoff example: <h:panelGroup> <f:event type="postAddToView" listener="#{bean.build}" /> </h:panelGroup> With this, assuming that you have a form.getType() of form1 and thus want to include <my:form1...

What is the difference between composite:insertFacet and composite:renderFacet?

jsf,jsf-2,composite-component,facet

The <cc:insertFacet> is not intented for the composite itself, but for composite's child which in turn expects a facet which needs to be provided externally. E.g. a <h:dataTable> which supports a <f:facet name="header"> (poor composite example, but it's just to give the idea): <cc:implementation> <h:dataTable> <cc:insertFacet name="header"> Which is to...

Cannot invoke listener method from f:ajax inside composite component

jsf,jsf-2,composite-component

Firstly, <cc:clientBehavior ... targets="#{cc.clientId}:datetype" /> The value of targets attribute is wrong. It's interpreted relative to the <cc:implementation>, however the #{cc.clientId} incorrectly expects it to be interpreted relative to its NamingContainer parent. Get rid of the #{cc.clientId}: prefix. <cc:clientBehavior ... targets="datetype" /> Don't forget to notify the author of the...

JSF Composite Component with conditional popup panel

jsf,richfaces,el,composite-component

The oncomplete attribute of the <a4j:commandLink> component must evaluate to a String. Here, your EL tries to invoke either a showMessage() or a submitToServer() java method depending on a boolean value, which are not found. what you want is a String with the JS function name, so just put function...

Tag for body definiton in composite component

jsf,jsf-2,composite-component

There the <cc:insertChildren> is for. <cc:implementation> ... <cc:insertChildren /> ... </cc:implementation> See also: Java EE 7 tutorial - Chapter 8.5: Composite Components ...

Validator in composite throws ClassCastException when using java.lang.Double value

validation,jsf,double,classcastexception,composite-component

I can't reproduce your problem. It works for me with Mojarra 2.2.10 on Tomcat 8.0.21 even without explicit type attribute in <cc:attribute type="java.lang.Double">. As a workaround you could explicitly declare a converter as below in composite's input component: <p:inputText ... converter="javax.faces.Double"> But Mojarra 2.1.7 is really old (Feb 2012). You...

jsf composite components getConvertedValue fired too early

jsf,children,composite-component

getStreet(), getCity()and getCountry() will not be updated untill the Update Model Values Phase, So it's normal to get null values while your are in the Process Validation Phase. An alternative solution is to use the binding attribute in your inputs, like: <p:inputText binding="#{cc.street}" size="30" required="true" /> And then use it...

Update attribute in JSF custom component expect full element ID path where as direct PrimeFaces component runs with short element ID path

jsf,primefaces,composite-component,commandbutton

That's because composite components are like <h:form>, <h:dataTable>, etc also naming containers. Their effect on ajax client IDs is outlined in this related question: Cannot find component with expression "foo" referenced from "bar" - <f:ajax> contains unknown id "foo" cannot locate it in context of component "bar". This is done...