templates - Extends Form Data in scout eclipse -
i have abstract form :
@formdata(value = abstractmyformdata.class, sdkcommand = formdata.sdkcommand.create) public abstract class abstractmyform extends abstractform { ... @order(10.0) @classid("myform.mytable") public class mytable extends abstractmytablefield { ... } }
this form data has table (mytable class template) inside :
public abstract class abstractmyformdata extends abstractformdata { private static final long serialversionuid = 1l; public abstractmyformdata() {} public mytable getmytable() { return getfieldbyclass(mytable.class); } public static class mytable extends abstractmytabledata { private static final long serialversionuid = 1l; public mytable() {} } }
my real form extends abstractmyform :
@formdata(value = myformdata.class, sdkcommand = formdata.sdkcommand.create) public class myform extends abstractmyform { ... @order(10.0) @classid("myform.mytable") public class mytable extends abstractmytablefield { ... } }
form data :
public class myformdata extends abstractmyformdata { public mytable getmytable() { return getfieldbyclass(mytable.class); } public static class mytable extends abstractmytabledata { private static final long serialversionuid = 1l; public mytable() {} } ..... ..... }
the problem both form datas (abstractmyformdata , myformdata) has implemented
public static class mytable extends abstractmytabledata
and scout complains has duplicate method getmytable()
.
but don't understand this. if myformdata extend abstractmyformdata myformdata must not have method inside because has parent.
how this? see formdata.sdkcommand.use
description might it, don't how use it.
second question witch might related how inject table in abstractmyform normal abstractform inject cancel button?
edit :
code classes :
abstract form
@formdata(value = abstractpurchasepriceformdata.class, sdkcommand = formdata.sdkcommand.create) @classid("41f0f405-b257-47e7-accf-270f5be158ce") public abstract class abstractmyform extends abstractform { /** * @throws org.eclipse.scout.commons.exception.processingexception */ public abstractmyform() throws processingexception { super(); } @order(10.0) public class mainbox extends abstractgroupbox { @order(10.0) public class mytable extends abstractmytablefield { } } @override protected string getconfiguredtitle() { return texts.get("abstractmyform"); } }
abstractmytablefield template :
import org.eclipse.scout.commons.annotations.formdata; import org.eclipse.scout.commons.annotations.order; import org.eclipse.scout.rt.client.ui.basic.table.columns.abstractintegercolumn; import org.eclipse.scout.rt.client.ui.basic.table.columns.abstractstringcolumn; import org.eclipse.scout.rt.client.ui.form.fields.tablefield.abstracttablefield; import org.eclipse.scout.rt.extension.client.ui.basic.table.abstractextensibletable; @formdata(value = abstractmytablefielddata.class, sdkcommand = formdata.sdkcommand.create, defaultsubtypesdkcommand = formdata.defaultsubtypesdkcommand.create) public abstract class abstractmytablefield extends abstracttablefield<abstractmytablefield.table> { @order(10.0) public class table extends abstractextensibletable { @order(10.0) public class namecolumn extends abstractstringcolumn { } @order(20.0) public class agecolumn extends abstractintegercolumn { } } }
for real form create form template :
and in main box add mytable :
insted :
@order(10.0) public class mainbox extends abstractgroupbox { }
do :
@order(10.0) public class mainbox extends abstractgroupbox { @order(10.0) public class mytable extends abstractmytablefield { } }
i hope more explicit time.
edit 2
i admit creating main box inside abstract form maybe not right approach, want achive have abstractmytablefield
in abstractmyformdata, can rely on server side forms extend abstractmyform has in form data can write 1 server method forms (returning abstractmyformdata).
formdata , form hierarchy
the formdata hierarchy reflects form hierarchy. if form hierarchy looks this:
myform |-- personform | \-- vipform. \-- companyform
your formdata hierarchy looks this:
myformdata |-- personformdata | \-- vipformdata \-- companyformdata
do not define mainbox twice
with example, have absolutely right code generated sdk contains compilation errors.
i have tried explain in your question form template, doesn’t make sense have main box in form template , in 1 in concrete form.
each form contains:
- 0..n variables
- 0..n key strokes (inner classes implementing ikeystroke)
- exactly 1 main box (inner class implementing igroupbox)
- 0..n toolbuttons (inner classes implementing itoolbutton)
- 1..n form handler (usually defined inner classes implementing iformhandler, since handler set parameter of abstractform.startinternal(iformhandler) handler can defined everywhere)
in case, when consider how concrete form (myform) looks like, notice have 2 mainbox:
- one corresponding
concreteform.mainbox
- one contributed abstract class , corresponding
abstractmyform.mainbox
have expected compile error (from pure jave point of view) seems work.
at runtime scout pick 1 of 2 mainbox
classes , use root of field tree. not sure if selected mainbox
defined scout or if randomly 1 of 2 (depending on java introspection class.getclasses()
return).
i not see ensured pattern have used. can define else in main box of concrete form:
@order(10.0) public class mainbox extends abstractgroupbox { @order(10.0) public class namefield extends abstractstringfield { @override protected string getconfiguredlabel() { return texts.get("name"); } } @order(20.0) public class okbutton extends abstractokbutton { } @order(30.0) public class cancelbutton extends abstractcancelbutton { } }
in case not have table extending abstractmytablefield
in concrete form, if 1 table defined in abstract class used form template.
@formdata configuration
you can influence generation of formdata formdata annotation. here 2 examples:
1/ if work group boxes defined templates can decide if groupboxdata should external class or not. can try ourself:
check or uncheck checkbox "create external formdata". can compare output (generated classes) , @formdata
annotation.
2/ tabledata can decided how structure in formdata (bean based or array based). see tabledata on eclipse wiki
usage of different options described in javadoc of @formdata
annotation.
if have moved field 1 class another, recommend regenerate formdatas sdk. (“update formdata classes” in scout explorer). might solve compilations problem.
Comments
Post a Comment