You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Max Grigoriev <da...@mail.ru> on 2003/09/20 19:21:36 UTC

SqueezeAdaptor question

Hello tapestry-user,

  I'm tring to use Table component. But when i use my object which is
  not implementing Serialiazble.
  I get an exception "Could not find an adaptor for class com.clearview.feedback.db.report.FeedbackCategory.".
  I've created adaptor for this class.

Adaptor code:

public class FeedbackAdaptor implements ISqueezeAdaptor {
  public static final String PREFIX = "C";
  public static final char PREFIX_CHAR = 'C';
  private static final String ZERO_CATEGORY = "-1";

  public String squeeze(DataSqueezer dataSqueezer, Object o) throws IOException {
    FeedbackCategory category = (FeedbackCategory) o;
    if (category != null)
      return category.getCode();
    else
      return ZERO_CATEGORY;
  }

  public Object unsqueeze(DataSqueezer dataSqueezer, String s) throws IOException {
    if (ZERO_CATEGORY.compareTo(s) != 0) {
      try {
        return FeedbackCategory.getCategoryByName(s, null);
      } catch (MiddleException e) {
        e.printStackTrace();
        throw new IOException(e.getMessage());
      }
    } else {
      return null;
    }
  }

  public void register(DataSqueezer dataSqueezer) {
    dataSqueezer.register(PREFIX, FeedbackCategory.class, this);
  }

  Now I've got some questions:

  1. Should i create every time for my custom objects such adaptors?
  2. Can somebody explain the procedure of registering these adaptors.
     How can i register my adapter.
     I look in sources of DataSqueezer and don't understand the reason
     of such strange registering.
 3. Where should i register my adaptor ?
 4. In page spec i described table components :
       <component id="tableView" type="contrib:TableView">
       ...
       </component>
       ...
       <component id="tableRows" type="contrib:TableFormRows">
                <binding name="row" expression="bean.currentCategory"/>
       </component>
       When i use my custom adapter, tapestry tries to invoke method
            setCurrentCategory(String ...)
       but i have only setCurrentCategory(FeedbackCategory category)
       So i get exception: java.lang.NoSuchMethodException

       When I don't use my adaptor and using SerializableAdaptor
       there's no such problem.

       What have i do to solve this problem?
       

-- 
Best regards,
 Max                          mailto:darkit@mail.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: SqueezeAdaptor question

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

>   I'm tring to use Table component. But when i use my object which is
>   not implementing Serialiazble.
>   I get an exception "Could not find an adaptor for class
com.clearview.feedback.db.report.FeedbackCategory.".
>   I've created adaptor for this class.

You are using the new table 'form' components :) Cool.

>   1. Should i create every time for my custom objects such adaptors?

At the moment, I am afraid so (unless your table model does not return
primary keys). This will probably change imminently, since it is an obvious
issue.

>   2. Can somebody explain the procedure of registering these adaptors.

Create your own engine by overriding BaseEngine and override the
createDataSqueezer() method.
Register the adaptor there, e.g. like this:

public DataSqueezer createDataSqueezer()
{
    return new DataSqueezer(_resolver, new ISqueezeAdaptor[] { /* put your
adaptors here */ });
}

>        <component id="tableRows" type="contrib:TableFormRows">
>                 <binding name="row" expression="bean.currentCategory"/>
>        </component>
>        When i use my custom adapter, tapestry tries to invoke method
>             setCurrentCategory(String ...)

Is it possible for FeedbackCategory.getCategoryByName(s, null); or some
other part of the code to return String rather than FeedbackCategory?
TableFormRows works like ListEdit, it will set in the row binding the
unsqueezed value of the object that was stored in the form. The class of
that value depends on the unsqueezing process.

If you are still having problems, try using TableRows rather than
TableFormRows -- it may be easier. In the mean time I will try to make the
conversion process mentioned above easier and will add more docs.

-mb


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org