Arne,

Can you please use the ResponseWriter.beginElement and ResponseWriter.endElement method for handling elements? It makes things a lot more flexible be cause the renderkit knows what kind of content you are passing into it. The more information we have without needing to parse the response, the better.

Example, instead of:

writer.write("<br>Foo</br>");

do the following
writer.beginElement("br", null);
writer.write("Foo");
writer.endElement("br");

It's a bit more code but is easier to read, and transform into other markups if need be.

Plus it will prevent the typo in your code below:

<br />Foo</br>

is not a valid markup anyway.  It should be:

<br>Foo</br> OR <br />Foo<br />

Scott

arne anka wrote:
thought, i mentioned it already -- there is no xhtml involved. i try to do it entirely in java:

public class FedoraObjectContentComponentUI extends UIOutput
{
    private byte[]         myObject = null;
    private String         myMime, myDS, myID;

    @Override
    public String getFamily()
    {
    return "fedoraobjectcontent";
    }

    @Override
    public String getRendererType()
    {
    return null;
    }

    @Override
    public void encodeBegin(FacesContext context) throws IOException
    {
    super.encodeBegin(context);
    final ResponseWriter writer = context.getResponseWriter();
    writer.write("<br/>Foo</br>");
    }

    @Override
    public Object saveState(FacesContext context)
    {
    Object values[] = new Object[5];
    values[0] = super.saveState(context);
    values[1] = myObject;
    values[2] = myMime;
    values[3] = myDS;
    values[4] = myID;
    return ((Object) (values));
    }

    @Override
    public void restoreState(FacesContext context, Object state)
    {
    Object values[] = (Object[]) state;
    super.restoreState(context, values[0]);
    myObject = (byte[]) values[1];
    myMime = (String) values[2];
    myDS = (String) values[3];
    myID = (String) values[4];
    }
}

and in faces-config.xml

<component>
    <component-type>component</component-type>
<component-class>my.package.Components.FedoraObjectContentComponentUI</component-class>
</component>

that's my component, basically.

On Wed, 23 Apr 2008 19:52:21 +0200, Andrew Robinson <[EMAIL PROTECTED]> wrote:

I should have asked this earlier, what is my:component? Do you use
ui:component in the root of the xhtml file? Is there getConverter /
setConverter methods on the component?

If you could provide a small code snippet from the facelet and the
component that it uses that would help.

-Andrew

On Wed, Apr 23, 2008 at 11:31 AM, arne anka <[EMAIL PROTECTED]> wrote:
snippet from faces-config.xml:
 <converter>
        <description>
        </description>
        <display-name>contentConverter</display-name>
        <converter-id>contentConverter</converter-id>

<converter-class>my.package.FaceletsElements.FedoraObjectContentConverter</converter-class>
 </converter>

 as said before -- it works with standard components. so it seems to be
something trivial i do not see.









 On Wed, 23 Apr 2008 19:21:37 +0200, Andrew Robinson
<[EMAIL PROTECTED]> wrote:


> Have you registered the converter in faces-config.xml properly? Please
> post your configuration for your converter
>
> On Wed, Apr 23, 2008 at 7:20 AM, arne anka <[EMAIL PROTECTED]> wrote:
>
> > hi,
> > i got my custom component (faclets based, not tomahawk or trinidad, > > extending UIOutput) working so far -- but my converter is not executed.
> >  if i attribute the converter to, say, h:outputText it works, so it
seems to
> > be ok.
> > my idea is, because i use my own rendere (getRendererType() returns
null)
> > maybe i need to call it myself?
> >  if so, how do i get hold of the converter?
> >
> >  both with
> >
> >  <my:component value="foo" converter="contentConverter" />
> >
> >  and with
> >
> >  <my:component value="foo">
> >        <f:converter converterId="contentConverter"/>
> >  </my:component>
> >
> >  getConverter() always returns null
> >
> >  thanks in advance
> >
> >
>






Reply via email to