Wade,
Stripes is finding your formatter but unless you omitted some lines from the log it looks like it isn't associating the formatter with your class. In the log you posted from the book's example it says "Adding auto-discovered Formatter" but that is missing in your log output.

Are you using the Stripes 1.5 jar file or did you build your own from source? The line number from your log doesn't match up with the Stripes source.

I don't see anything obvious wrong with your code but your formatter is definitely not being used. I'm not sure what to suggest beyond making your source available somewhere to test with.

Aaron

Wade Marshall wrote:
I am trying to copy the example in Chapter 5 of the Stripes book (Daoud) for Type Converters and Model Classes, but it doesn't work.

My model class is called ProductGroup, their model class is called Contact.

The good news (I think) is that my app logs seem to indicate the formatter is being picked up by the configuration done in web.xml (see logs below)

The bad news is that my generated HTML (wrong) looks like this.....
<a 
href="/imgweb/PreCardOrder.action?productGroup=com.yff.db.model.ProductGroup%40201adc">
and theirs (correct) looks like....
<a href="/email_07/ContactForm.action?contact=2">

If I'm right the configuration of the formatter being ok.....how might I go about debugging this problem from here ?

Or if there's something else I should look, let me know too.
Thanks all,
Wade.

==========================================================

Email_07 Application Log

[16:08:00] DEBUG net.sourceforge.stripes.config.RuntimeConfiguration - Adding auto-discovered Formatter [class stripesbook.ext.ContactFormatter] for [class stripesbook.model.Contact] (from type parameter)

Email_07 Formatter

package stripesbook.ext;

import java.util.Locale;
import net.sourceforge.stripes.format.Formatter;
import stripesbook.model.Contact;

public class ContactFormatter implements Formatter<Contact> {
    public String format(Contact contact) {
        return String.valueOf(contact.getId());
    }
    public void init() { }
    public void setLocale(Locale locale) { }
    public void setFormatType(String type) { }
    public void setFormatPattern(String pattern) { }
}

Email_07 Model Class

package stripesbook.model;

import java.util.Date;

public class Contact {
...
    private Integer id;
}

==========================================================

My Application Log

16:33:56,047 DEBUG net.sourceforge.stripes.config.RuntimeConfiguration:194 - Found Formatter [class com.yff.web.ext.ProductGroupFormatter] - type parameters: [class com.yff.db.model.ProductGroup]

My Formatter

package com.yff.web.ext;

import java.util.Locale;
import com.yff.db.model.ProductGroup;
import net.sourceforge.stripes.format.Formatter;

public class ProductGroupFormatter implements Formatter <ProductGroup>{

    @Override
    public String format(ProductGroup productGroup) {
        return productGroup.getId();
    }

    @Override
    public void init() {}

    @Override
    public void setFormatPattern(String pattern) {}

    @Override
    public void setFormatType(String type) {}

    @Override
    public void setLocale(Locale locale) {}
}

My ProductGroup Model Class

package com.yff.db.model;
...

public class ProductGroup implements Serializable
{
    ....
    private String id;
@Id
    public String getId()
    {
        return id;
    }
...
}


My JSP

<stripes:link beanclass="com.yff.web.action.PreCardOrderActionBean" >
  <stripes:param name="productGroup">${productgroup}</stripes:param>
   Create
</stripes:link>

------------------------------------------------------------------------

------------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to