On Wed, Apr 22, 2009 at 10:37 AM, Döring Markus
<[email protected]> wrote:
> I've tried this, but I always get an NPE when I have an own converter and the
> "Select Color Popup" opens:
>
> Caused by: java.lang.NullPointerException
> at
> org.apache.myfaces.trinidadinternal.renderkit.core.pages.ColorPickerJSP._getConverter(ColorPickerJSP.java:147)
> at
> org.apache.myfaces.trinidadinternal.renderkit.core.pages.ColorPickerJSP.service(ColorPickerJSP.java:86)
> at
> org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry._service(GenericEntry.java:244)
> at
> org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry.service(GenericEntry.java:228)
> at
> org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry.renderView(GenericEntry.java:109)
> at
> org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:178)
> at
> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
> at
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
> ... 27 more
I see it fails because now a req param is missing.
but internally the _getConverter() still uses the Trinidad ColorConv. Odd...
>
> My XHTML:
> <tr:inputColor label="BGColor"
> value="#{data['editItem'].headerBgColor}">
> <tcc:colorStringConverter />
> </tr:inputColor>
>
> My Converter:
>
> import java.awt.*;
>
> import javax.faces.component.*;
> import javax.faces.context.*;
> import javax.faces.convert.*;
>
> import org.apache.myfaces.trinidad.convert.*;
>
> public class ColorStringConverter implements Converter {
>
> private static final ColorConverter TR_CONVERTER = new
> ColorConverter();
>
> public Object getAsObject(FacesContext context, UIComponent component,
> String value) {
> Color color = (Color) TR_CONVERTER.getAsObject(context,
> component, value);
> return getAsString(context, component, color);
> }
>
> public String getAsString(FacesContext context, UIComponent component,
> Object value) {
> return TR_CONVERTER.getAsString(context, component, value);
> }
> }
>
>
> BTW, a bit of topic, but the "Select Color Popup" opens in a new browser
> window. I have
> <context-param>
>
> <param-name>org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS</param-name>
> <param-value>true</param-value>
> </context-param>
> in my web.xml.
> Would be nice to see the popup use the lightweight dialogs framework at some
> time in the future.
Can you bring this up on the dev@ list, as a separate topic ?
>
> Best regards
> Markus
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[email protected]] Im Auftrag von
> Matthias Wessendorf
> Gesendet: Mittwoch, 22. April 2009 09:44
> An: MyFaces Discussion
> Betreff: Re: [Trinidad] Saving an inputColor to an EJB backing bean
>
> On Wed, Apr 22, 2009 at 9:36 AM, Döring Markus
> <[email protected]> wrote:
>> Hi all,
>>
>>
>>
>> my goal is to have an EJB backing bean like the following:
>>
>>
>>
>> @Entity
>>
>> public class EntityBean {
>>
>> //... id stuff and else properties
>>
>>
>>
>> private String color;
>>
>>
>>
>> public String getColor() {
>>
>> return color;
>>
>> }
>>
>> public void setColor(String color) {
>>
>> this.color = color;
>>
>> }
>>
>> }
>>
>>
>>
>> and directly getting / setting the value from / to and <tr:inputColor>
>>
>>
>>
>> <ui:composition>
>>
>> <tr:panelFormLayout>
>>
>> <tr:inputColor label="Select color" value="#{entity.color}">
>>
>> </tr:panelFormLayout>
>>
>> </ui:composition>
>>
>>
>>
>> Is is in some possible?
>>
>> I already tried it with the <tr:convertColor> converter, but the value that
>> is passed to the entity is always a java.awt.color instance (causing an
>> argument type mismatch on submit of the form).
>>
>> One way I can think of is to put @Transient getter / setter in the
>> EntityBean that convert from color to string and vice versa. But this would
>> be ugly because there will be more than one color in the EntityBean what
>> would result in A LOT OF duplicated getter/setter just for converting stuff.
>
> have you tried a custom converter that internally uses the Trinidad
> ColorConverter
> but returns a String of the java.awt.Color ?
>
> Like:
>
> getAsObject(...)
> {
> ...
> Color c = ctrinidadColorConv.getAsObject(...);
> return c.toString();
> }
>
> -M
>
>>
>>
>>
>> Any easy way to handle this?
>>
>>
>>
>> Thanks for help
>>
>> Markus
>>
>>
>>
>> PS. I'm using JBoss 4.2.2, Myfaces 1.1.5, Trinindad 1.0.7, Facelets 1.1.13
>
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>
--
Matthias Wessendorf
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf