You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Karl Kildén <ka...@gmail.com> on 2015/02/13 10:50:46 UTC

Custom converter as tag with attributes?

Hello,

I want to create a converter and instead of having f:attributes (need many)
I want to create my own tag. Using myfaces 2.2.x

I did this:

@FacesConverter("myconverter")
public class MyConverter extends ConverterHandler implements Converter {
 public MyConverter(ConverterConfig config) {
super(config);
}



<tag>

<tag-name>myconverter</tag-name>
<converter>
<converter-id>myconverter</converter-id>
<handler-class>se.raindance.mp.NumberConverter</handler-class>
</converter>
<attribute>
<name>minFraction</name>
<name>maxFraction</name>
<name>defaultValue</name>
</attribute>
</tag>


If I remove extends ConverterHandler I get exception that I need to
implement TagHandler... But all I want is to be able to supply some
attributes in my facelet. Anyways the problem is that my constructor is
getting called but not getAsObject nor getAsString...

I also have this:

<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/my.taglib.xml</param-value>
</context-param>


What am I missing?

Re: Custom converter as tag with attributes?

Posted by Karl Kildén <ka...@gmail.com>.
Seems like a bug that I need to implement TagHandler. If I omit it this is
the exception I get:

https://gist.github.com/anonymous/5b7204de5e9cc9f65c02

On 13 February 2015 at 10:50, Karl Kildén <ka...@gmail.com> wrote:

> Hello,
>
> I want to create a converter and instead of having f:attributes (need
> many) I want to create my own tag. Using myfaces 2.2.x
>
> I did this:
>
> @FacesConverter("myconverter")
> public class MyConverter extends ConverterHandler implements Converter {
>  public MyConverter(ConverterConfig config) {
> super(config);
> }
>
>
>
> <tag>
>
> <tag-name>myconverter</tag-name>
> <converter>
> <converter-id>myconverter</converter-id>
> <handler-class>se.raindance.mp.NumberConverter</handler-class>
> </converter>
> <attribute>
> <name>minFraction</name>
> <name>maxFraction</name>
> <name>defaultValue</name>
> </attribute>
> </tag>
>
>
> If I remove extends ConverterHandler I get exception that I need to
> implement TagHandler... But all I want is to be able to supply some
> attributes in my facelet. Anyways the problem is that my constructor is
> getting called but not getAsObject nor getAsString...
>
> I also have this:
>
> <context-param>
> <param-name>facelets.LIBRARIES</param-name>
> <param-value>/WEB-INF/my.taglib.xml</param-value>
> </context-param>
>
>
> What am I missing?
>

Re: Custom converter as tag with attributes?

Posted by Gerhard Petracek <ge...@gmail.com>.
hi karl,

in deltaspike that should work since v1.1.0 once you add javassist.
at least we have tests for it which pass...

regards,
gerhard

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans



2015-02-16 8:57 GMT+01:00 Karl Kildén <ka...@gmail.com>:

> This is a bug in the Deltaspike and the Myfaces way of making @Inject work
> for a Converter. The wrapper thingy breaks it. If I remove my injection
> points it works. I will create a sample and then issues for both projects
>
> Cheers
>
> On 13 February 2015 at 10:50, Karl Kildén <ka...@gmail.com> wrote:
>
> > Hello,
> >
> > I want to create a converter and instead of having f:attributes (need
> > many) I want to create my own tag. Using myfaces 2.2.x
> >
> > I did this:
> >
> > @FacesConverter("myconverter")
> > public class MyConverter extends ConverterHandler implements Converter {
> >  public MyConverter(ConverterConfig config) {
> > super(config);
> > }
> >
> >
> >
> > <tag>
> >
> > <tag-name>myconverter</tag-name>
> > <converter>
> > <converter-id>myconverter</converter-id>
> > <handler-class>se.raindance.mp.NumberConverter</handler-class>
> > </converter>
> > <attribute>
> > <name>minFraction</name>
> > <name>maxFraction</name>
> > <name>defaultValue</name>
> > </attribute>
> > </tag>
> >
> >
> > If I remove extends ConverterHandler I get exception that I need to
> > implement TagHandler... But all I want is to be able to supply some
> > attributes in my facelet. Anyways the problem is that my constructor is
> > getting called but not getAsObject nor getAsString...
> >
> > I also have this:
> >
> > <context-param>
> > <param-name>facelets.LIBRARIES</param-name>
> > <param-value>/WEB-INF/my.taglib.xml</param-value>
> > </context-param>
> >
> >
> > What am I missing?
> >
>

Re: Custom converter as tag with attributes?

Posted by Karl Kildén <ka...@gmail.com>.
This is a bug in the Deltaspike and the Myfaces way of making @Inject work
for a Converter. The wrapper thingy breaks it. If I remove my injection
points it works. I will create a sample and then issues for both projects

Cheers

On 13 February 2015 at 10:50, Karl Kildén <ka...@gmail.com> wrote:

> Hello,
>
> I want to create a converter and instead of having f:attributes (need
> many) I want to create my own tag. Using myfaces 2.2.x
>
> I did this:
>
> @FacesConverter("myconverter")
> public class MyConverter extends ConverterHandler implements Converter {
>  public MyConverter(ConverterConfig config) {
> super(config);
> }
>
>
>
> <tag>
>
> <tag-name>myconverter</tag-name>
> <converter>
> <converter-id>myconverter</converter-id>
> <handler-class>se.raindance.mp.NumberConverter</handler-class>
> </converter>
> <attribute>
> <name>minFraction</name>
> <name>maxFraction</name>
> <name>defaultValue</name>
> </attribute>
> </tag>
>
>
> If I remove extends ConverterHandler I get exception that I need to
> implement TagHandler... But all I want is to be able to supply some
> attributes in my facelet. Anyways the problem is that my constructor is
> getting called but not getAsObject nor getAsString...
>
> I also have this:
>
> <context-param>
> <param-name>facelets.LIBRARIES</param-name>
> <param-value>/WEB-INF/my.taglib.xml</param-value>
> </context-param>
>
>
> What am I missing?
>