Note that there are some explanatory texts on larger screens.

plurals
  1. POManaged Bean as Facelet parameter lets composite component prevent resolving
    primarykey
    data
    text
    <p>In the given case, I want to use a facelet with different ManagedBeans, so the regarding action-bean is given as an parameter:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" &gt; &lt;h:body&gt; &lt;ui:include src="ratings.xhtml" &gt; &lt;ui:param name="createAction" value="#{myOneCreateAction}" /&gt; &lt;ui:param name="ratings" value="#{context.ratings}" /&gt; &lt;/ui:include&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>I'm giving the create action as parameter <code>value="#{myOneCreateAction}"</code>.</p> <p>Within that facelet is a component also being used several times on other pages - so I try to refactor it in a composite component.</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:io="http://java.sun.com/jsf/composite/inoutComponents"&gt; &lt;ui:composition&gt; &lt;rich:dataTable id="ratingTblId" value="#{ratings}" var="rating"&gt; &lt;rich:column&gt; &lt;io:removeButton id="removeButton" actionMethod="#{createAction.removeRating}" immediate="true" render=":#{rich:clientId('ratingTblId')}" /&gt; &lt;h:commandButton id="removeButton2" actionListener="#{createAction.removeRating}" immediate="true" &gt; &lt;f:ajax render="ratingTblId" /&gt; &lt;/h:commandButton&gt; &lt;/rich:column&gt; &lt;/rich:dataTable&gt; &lt;/ui:composition&gt; &lt;/html&gt; </code></pre> <p>See, how the method is given as <code>actionMethod="#{createAction.removeRating}"</code> to the component. This component itself looks like following:</p> <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:cc="http://java.sun.com/jsf/composite"&gt; &lt;!-- INTERFACE --&gt; &lt;cc:interface&gt; &lt;cc:attribute name="actionMethod" targets="remove" method-signature="void f(javax.faces.event.ActionEvent)"/&gt; &lt;cc:attribute name="render" required="false" /&gt; &lt;/cc:interface&gt; &lt;!-- IMPLEMENTATION --&gt; &lt;cc:implementation&gt; &lt;h:commandButton id="remove" actionListener="#{cc.attrs.actionMethod}" onclick="if (!confirm('Do you really?')) { return false; }"&gt; &lt;f:ajax execute="@this" render="#{cc.attrs.render}" /&gt; &lt;/h:commandButton&gt; &lt;/cc:implementation&gt; &lt;/ui:composition&gt; </code></pre> <p>and last but not least, the managed bean</p> <pre><code>Name("myOneCreateAction") @Scope(ScopeType.CONVERSATION) public class MyOneCreateAction { ... public void removeRating(ActionEvent ev) { // do something } ... } </code></pre> <p>Surprisingly, while the removeButton2 correctly jumps into the right function, the composite components version returns a </p> <pre><code>javax.faces.event.AbortProcessingException: Target Unreachable, identifier 'createAction' resolved to null </code></pre> <p>instead. Am using Mojarra JSF 2.1.26 with Seam 2.3.1.CR1. There are no nested composite components. When replacing the composite component parameter to <code>#{myOneCreateAction.removeRating}</code>, it works like expected.</p> <p>Has anybody seen this before? Am I blind? Any work-arounds known... ? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload