Re: [Wicket-user] General question on DetachableModel, edit form for based on set and components

2007-04-25 Thread Francois Armand
Le mardi 24 avril 2007 à 08:08 -0700, Igor Vaynberg a écrit :
> On 4/24/07, Francois Armand <[EMAIL PROTECTED]> wrote:
> i only have time to help you with one, so here goes 
> [resolve my pb in just a few lignes of code]

> -igor

Wow. thanks you very much for you answer, now I'm _really_ impressed by
Wicket. 

The way it handle this problem, and more generally how wicket handle
nested and recursive structure is quite elegant. And I think I begin to
understand how the framework works, the possibilities are, hum,
exciting.

I think I will push a little bit further my investigation on this
fabulous framework :)

Thanks you very much !

Francois


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] General question on DetachableModel, edit form for based on set and components

2007-04-24 Thread Igor Vaynberg

On 4/24/07, Francois Armand <[EMAIL PROTECTED]> wrote:i only have time to
help you with one, so here goes

(I think that the printing of an entry would work on the same model,

say :
* given an entry {
  print the dn ;
  for each attribute {
select a formatting method;
for each value {
  print the value formatted according to the selected method;
}
  }
}
)



first you only need a top level detachable model

class DetachableEntryModel extends LoadableDetachableModel {
 private final String dn;
 private final SpringEntryDao dao;

 public DetacahbleEntryModel(Entry e, SpringEntryDao dao) {
 super(e);
 this.dn=e.getDn();
 this.dao=dao;
  }

  Object load() {
   return dao.get(dn);
   }
}


class PrintPanel extends Panel {
   public PrintPanel(String id, IModel entry) {
   // given an entry
   super(id, new CompoundPropertyModel(entry));

   //   print the dn ;
   add(new Label("dn"));
   add(new PropertyListView("attributes") {
  populateItem(ListItem item) {
 //  for each attribute {
 Attribute a=item.getModelObject();
 // select a formatting method;
 final AttributeFormatter f=;

  item.add(new Label("name"));
  item.add(new ListView("values") {
 populateItem(ListItem item) {
 Object value=item.getModelObject();
 String str=f.format(value);
 add(new Label("value", str));
  }
  });
  });
}
 }
}



dn: 










-igor
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] General question on DetachableModel, edit form for based on set and components

2007-04-24 Thread Francois Armand
Hello everybody, 

I'm quite new to Wicket, and to web component framework to. 
Until now I just try simple examples, which seem to work (really) fine.
So now, I want to pass to a little more complexe one, to try to
understand how things work in Wicket (version 1.3). 

I work on LDAP directories, so I play with *entries*, identified by
there "dn". Each entry has a Set of *attributes*. Attributes are linked
to an unique entry, are identified by there "name", and have a Set of
*values*. A spring managed DAO allows to do CRUD actions on entries. A
summary of these object is given at the end of the email.

I think I understand that I have to take care that objects are
detachable. I succeed in using spring annotation to use a spring proxy
to connect to my DAO and retrieve an entry and write his it on screen.

Now, I want to see how powerful is wicket, and for that I want to
translate this algo to edit an entry 
* given an entry {
  print the dn ;
  for each attribute {
select an input method base on the name of the attribute;
for each value {
  add an edit box according to the input method;
}
  }
}

(I think that the printing of an entry would work on the same model,
say :
* given an entry {
  print the dn ;
  for each attribute {
select a formatting method;
for each value {
  print the value formatted according to the selected method;
}
  }
}
)

If I well understand how works wicket, I need to define a detachable
model for the "entry" object, and a detachable model for each "type" of
attribute. Then, I have to play with repeaters at attribute and value
level. Or perhaps I need to define a component for each attribute ?
Well, as you see, I don't know where to begin. I look carefully in
examples and wiki, but I don't really find how to put concept together. 
Could you, please, point me some entries or give me some advice in the
main line of what I have to do to implement my algo ?


Any help would be welcome, 
Francois

-
PS : to detail a little bit mare, I have these objects (and I have to
deals with them, I cannot change them because I relay upon a framework):

SpringEntryDao {
  Entry get(String dn);
  ...
}

Entry { 
  String dn:
  Set attributes;
  Attribute getAttribute(String name)
  void setAttribute(Attribute attribute)
  ...
}

Attribute {
  String name;
  Set values;
  Value getValue(); //return next value if one remain, null otherwise
  Set getValues(); //return a set of all value
  ...
}

Value {
  Object value;
  Object getValue();
  ...
}



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user