Même si on peut jouer avec le setStartRow et setEndRow il n'est pas toujours très pratique de positionner des boutons dans un formulaire comme on le désire.
Dans certains cas je n'utilise pas de ButtonItem mais plutôt un CanvasItem qui va inclure un HLayout contenant lui même des boutons et des LayoutSpacer pour assurer leur centrage, on peut éventuellement fixer la largeur de ceux-ci :
public class ValiderAnnulerItem extends CanvasItem{
private MyDialogButton btnValidate ;
private MyDialogButton btnCancel ;
public MyDialogButton getBtnValidate() {
return btnValidate;
}
public void setBtnValider(MyDialogButton btnValidate) {
this.btnValidate = btnValidate;
}
public MyDialogButton getBtnAnnuler() {
return btnCancel;
}
public void setBtnAnnuler(MyDialogButton btnCancel) {
this.btnCancel = btnCancel;
}
HLayout lesBoutons = new HLayout();
public ValiderAnnulerItem(){
this.setTitle("");
}
public void initialize(){
lesBoutons.setHeight(btnValidate.getHeight() +5);
lesBoutons.addMember(new LayoutSpacer());
lesBoutons.addMember(btnValidate);
lesBoutons.addMember(new LayoutSpacer());
lesBoutons.addMember(btnCancel);
lesBoutons.addMember(new LayoutSpacer());
this.setCanvas(lesBoutons);
}
}
A l'utilisation:
ValiderAnnulerItem canvasButtons = new ValiderAnnulerItem();
canvasButtons.setBtnValider(btnValidate);
canvasButtons.setBtnAnnuler(btnCancel);
canvasButtons.initialize();
..............
f.setItems(...........,canvasButtons);
Even if we can position ButtonItem in a DynamicForm with the setStartRow and setEndRow, it's not always very practical to get the appearance we like to obtain.
So sometime I use in place a CanvasItem subclass with IButton subclass (which fire business events via the SimpleEventBus). In this case we can use a normal Hlayout (we could use a Vlayout depending of a property...) to setup the arrangement we need. I use LayoutSpacer with or without setting their width to center the buttons.
Some notes about what I met during my SmartGWt development.(english version at the bottom of the page)
mardi 27 septembre 2011
vendredi 9 septembre 2011
Un objet Session / Session Object to share objects
Avant d'implémenter le SimpleBusEvent j'ai eu besoin d'échanger des objets entre différents composants de mon application (Par exemple des attributs d'un record de listgrid lors de sa sélection ou le record en entier dont je peux avoir besoin dans un autre panel) .
Une partie du code
public class Session {private static HashMap<String, Object> map = new HashMap<String,Object>();
public static void put(String cle, Object objet){
map.put(cle, objet);
}
public static Object get(String cle){
return map.get(cle);
}
public static void putNomRubrique(String chaine){
map.put("NomRubrique", chaine);
}
public static String getNomRubrique(){
return (String) map.get("NomRubrique");
}
public static RubriqueDTO getRubrique(){
return (RubriqueDTO) map.get("Rubrique");
}
public static void putVariable(VariableDTO variable){
.....
Before I could use the SimpleEventBus I was in the need of using some object in differents place of my application, the component need some way of using common data (for example if I need a record data after its selection in a ListGrid in a panel A and which I need sometime later in a panel B) . So I wrote a simple Session class acting like Asp.net or Php Session but for client side.
To avoid the problems of typing error on the key string I use typed get and put method for the common object I use. I kept anyway the normal way of using the HashMap <String>, <Object> with two methods, I don't know if it's a good idea but it's practical during development or test something without be obliged to create the two methods. It make a lot of method to write but eventually it's really practise. I know that it is not so good writing manner because if you don't put the value you are interested in in the right place it's difficult to find errors.
Inscription à :
Articles (Atom)