Scout eclipse form template

断了今生、忘了曾经 提交于 2020-01-06 03:06:33

问题


I see in the tree representing my applications in the Scout Explorer view that I have two subfolders under the template node :

  • Forms
  • Form Fields

I know how to add form fields and its pretty simple, but I don't know how to create a form template and I can't find it on internet.

Marko

EDIT :

Now I figure out how to add form to From template folder. You just need to add abstract tag and then you can create new form from this template.

Now I need to change default main box class from : AbstractGroupBox to AbstractMyGroupBox. To be understand, what I need is to set somehow inside AbstractMyForm, that all form that come from AbstractMyForm template have instead :

public class TestFromForm extends AbstractMyForm

...

@Order(10.0)
@ClassId("e23ebc80-d948-4e23-aff6-ae49d3278331")
public class MainBox extends AbstractGroupBox {
    @Order(10.0)
    @ClassId("571bc88f-67ee-454d-b6ce-9616bc43bf74")
    public class OkButton extends AbstractOkButton {
    }
    @Order(20.0)
    @ClassId("66969857-002f-4689-981e-20ab60bbaf0e")
    public class CancelButton extends AbstractCancelButton {
    }
}

have this :

@Order(10.0)
@ClassId("e23ebc80-d948-4e23-aff6-ae49d3278331")
public class MainBox extends AbstractMyGroupBox {

}

回答1:


You are right; there isn't any support in the Scout Perspective to create a form template. You need to use the Java tooling from the IDE.


Form template

A form template is nothing more than an Abstract class extending org.eclipse.scout.rt.client.ui.form.AbstractForm. Your template can be located where you want (where it makes sense, depending on your code organization). Possible package: <your_app>.client.ui.template.form.

This is a minimal example:

import org.eclipse.scout.commons.exception.ProcessingException;
import org.eclipse.scout.rt.client.ui.form.AbstractForm;

public abstract class AbstractMyForm extends AbstractForm {

  /**
   * @throws ProcessingException
   */
  public AbstractMyForm() throws ProcessingException {
    super();
  }
}

Form and Mainbox

Be aware that a Form (used with a template or not) has only one MainBox (a root group box containing a tree of child fields). It is loaded during Form initialization. (see extended answer based on an example).

From the implementation of the private method AbstractForm.getConfiguredMainBox() I can deduce that only the first inner class implementing IGroupBox is selected.

Therefore Form Templates are suitable to mutualize logic on at form level. Sometime also some form handlers or tool buttons.

If the idea is to mutualize common fields between multiple forms, a possibility is to use a field template for the main box itself:

@Order(10.0)
public class MainBox extends AbstractMyTemplateGroupBox {
    //…
}

Without knowing more on the use case, it is hard to tell what you should do.



来源:https://stackoverflow.com/questions/25931621/scout-eclipse-form-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!