Wade Marshall <wade...@...> writes:
> 
> 
> 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 Formatterpackage 
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 
Classpackage stripesbook.model;import java.util.Date;public class Contact 
{...    private Integer 
id;}==========================================================My Application 
Log16: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 Formatterpackage 
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>{     <at> Override    public String format
(ProductGroup productGroup) {        return productGroup.getId();    }     <at> 
Override    public void init() {}     <at> Override    public void 
setFormatPattern(String pattern) {}     <at> Override    public void 
setFormatType(String type) {}     <at> Override    public void setLocale(Locale 
locale) {}    }My ProductGroup Model Classpackage com.yff.db.model;...public 
class ProductGroup implements Serializable {    ....    private String id;    
     <at> 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
> stripes-us...@...
> https://lists.sourceforge.net/lists/listinfo/stripes-users
> 

Hi Wade (and Stripes Users) --

This is my first ever post as I just got Freddy's book last week and am working 
through the examples as well.

Coincidentally, I too am in Ch. 5 and ran into a little bit of trouble in this 
section here as well.  My problem was w/ the PhoneNumberFormatter and the issue 
I was having was that after having applied the formatter, I wasn't seeing:

    555-123-4567

In my view or updated forms.  Instead, I was seeing:

    org.stripesbook.quickstart.model.phonenum...@69a4cb 

After quite a bit of searching around, I found my problem to be that I am using 
Stripes QuickStart, which sets one of the default extension directories to be:

    org.stripesbook.quickstart.extension

But my package (as per the source code in the book) is:

    org.stripesbook.quickstart.ext

My problem was that Stripes wasn't finding my formatter.

I just thought I'd mention this for anyone else that is going through the 
(excellent) Stripes book and stumbles in this section.




------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to