Hey Matt,

thanks for your help and your hint to an additional ELResolver. I've already thought that is a little gap in the spec. Maybe this could be added to the wiki-page because without your fix the CC-feature is not (really) usable in JSF2.0/2.1 I think.

Best regards,
Sven


Am 27.07.2011 20:10, schrieb Matt Benson:
Hi,
   This looks like https://issues.apache.org/jira/browse/MYFACES-2552
where I have noted my workaround.

HTH,
Matt

On Wed, Jul 27, 2011 at 1:00 PM, S. Bunge<sbung...@nnga.de>  wrote:
Hi all,

I got an issue using the composite components feature of jsf2.0.
It's quite possible that I'm using the feature the wrong way.

I created such component to combine a label and an h:inputText. If I use
it with string objects all works fine but when I start to use instances of
custom classes and a converter registered in the faces-config.xml must
handle the object, it fails.

I use MyFaces 2.0.7 with a tomcat 6.0.32. I removed the label and other
stuff in my example:

My custom component (cc-ns: "http://java.sun.com/jsf/composite";)
...
<cc:interface>
  <cc:attribute name="id" required="true" />
  <cc:attribute name="value" required="true" />
</cc:interface>
<cc:implementation>
  <h:inputText id="inputText" value="#{cc.attrs.value}" />
</cc:implementation>
...

I named the file 'myCC.xhtml' in /resources/myComponents/ so I can use it
with ns-declaration:
'xmlns:my="http://java.sun.com/jsf/composite/myComponents";' in my facelets.

I created also a bean named 'helloWorldBacking' with getMuh/setMuh and it
returns an Object of Type 'Muh'. A converter is registered in the
faces-config with 'converter-for-class' to handle the conversation between
view and model for the type.

If I use<h:inputText id="abc" value="#{helloWorldBacking.muh}" />
directly in my facelet it works like a charm. The converter is called and
get/set is called with the right object in the update model phase. But if I
switch to the myCC-component I get an exception:

Caused by: javax.el.ELException: /resources/myComponents/myCC.xhtml at
line 17 and column 62 value="#{cc.attrs.value}":
/helloWorld.xhtml at line 17 and column 71
value="#{helloWorldBacking.muh}": Cannot convert asdfasd of type class
java.lang.String to class elproblem.Muh
    at
org.apache.myfaces.view.facelets.el.TagValueExpression.setValue(TagValueExpression.java:129)
    at
org.apache.myfaces.view.facelets.el.LocationValueExpression.setValue(LocationValueExpression.java:120)
    at javax.faces.component.UIInput.updateModel(UIInput.java:379)

Maybe the behavior is slightly different with the used EL-library (I tried
jasper-el of the tomcat and EL2.2 of the glassfish) -- 'sometimes' it works
with none-null values the right way but if the bean returns 'null' if fails
every time.

My investigations came to a stop at following point:
_SharedRendererUtils#findUIOutputConverter doesn't get the outer value
binding of the composite component and can't determine the type. So no
converter is called and he tried to update
the model with a String.
If I set the type to the cc:attribute it doesn't work. That would be a bad
solution anyway because the composite component must be abstract
(otherwise I could call the right converter by id :-) )

So my questions: Do I use the composite components feature the right
way? If not: What is my fault? What are your suggestions?

Thanks for your help,
Sven

Reply via email to