But i don't get quite how you would do it then in a concrete non abstract class that does the things a idlist does now.

Where sits the implementation that gives you the Display value and the ID value of the objects that are in the list?
How would you do that in one implementation?


I also didn't like to inherit from ArrayList (or any other List class/interface) thats why i have the simple interface.

this is for example a implementation i currently have:

private class IdList extends ArrayList implements IIdList
{
       public void detach()
       {
           clear();
       }

public void attach()
{
if (size() == 0)
{
AuthorizationServiceImpl.getInvoker().execute(new HibernateCommand()
{
public void execute(Session session) throws HibernateException
{
List lst = session.createQuery("from " + Group.class.getName() + " order by name").list(); //$NON-NLS-1$ //$NON-NLS-2$
addAll(lst);
}
});
}
}


       public String getDisplayValue(int row)
       {
           return ((Group) get(row)).getName();
       }

       public String getIdValue(int row)
       {
           return ((Group) get(row)).getId().toString();
       }

       public Object getObjectById(String id)
       {
           if (id == null) return null;

           final Long longId = new Long(id);
           for (int i = 0; i < size(); i++)
           {
               if (((Group) get(i)).getId().equals(longId))
               {
                   return get(i);
               }
           }
           return null;
       }
}

So it is build around a hibernate object "Group"
In the deattach i do clear to get rid of all the things attach loads (it does the query over the groups table)
Then we have the getDisplay and getIdValue calls that returns what i want to see and what the identifier is for the Group object.
And the last is needed by the AbstractCombo component so that it can get the right object from the id that the request gives.


I can think of one way to do this and that is using reflection (then you can say this method name returns the display value and that the id value)
But that shouldn't be the default thing...


johan



Jonathan Locke wrote:


in general, no non-generic class like this should inherit from ArrayList. it may seem convenient now, but later it will be a mistake. we aggregate an arraylist and delegate to it as needed.


also, why should it be abstract?  can you send a use case or two?
Johan Compagner wrote:

Can you tell me what you would do in that concrete class??
Or do you mean the current interface is removed and all the methods of that interface are moved to that abstact IdList?
That could be then a IdList is always a arraylist but i can live with that.


johan



Jonathan Locke wrote:


eelco,

it's getting on towards 2AM, so i may not have thought this ALL the way through, but i think i have a solution to the ValidationErrorModelDecorator problem.

it's simple and elegant. override getModel() in FormComponent so that a new Model(getRequestString()) is returned if there is a validation error for the component. if you want to take a crack at this while i'm gone... be my guest. also, i'd like to get rid of IIdList and the IdListAdaptor and just have a simple concrete IdList. i don't see the value in that interface. finally, i'd like to get rid of IFormComponentPersistenceManager (which, sadly, i think i may have suggested some weeks ago in an email i didn't think through very well... ). in any case, i can do these things on wednesday if you don't get to them. btw, i really like the validation delegate, although i rearranged it a bit to make it a singleton with more restricted scope.

      jon



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop





------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop





------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Wicket-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to