Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How can I pass additional variables to injectFieldsInternal()
How can I pass additional variables to injectFieldsInternal() [message #1032799] Wed, 03 April 2013 12:52 Go to next message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
I'm trying to dynamically create fields on a Form based upon metadata that I get from a database before the form is created. The Form is going to be called via a Menu on a record in a AbstractTablePage.

I've managed to find out how to inject fields with the use of overriding the injectFieldsInternal() function, but sofar I havent yet figured out how I can pass a value to indicate how many fields need to be injected.

How can I best do this?

Relevant code in the Form:
@Order(10.0)
public class MainBox extends AbstractGroupBox {

    @Override
    protected void injectFieldsInternal(List<IFormField> fieldList) {

      //int params = this.reportId.intValue();
      int params = 1;

      for (int i = 1; i < params; i++) {
        final int param = i;
        fieldList.add(new AbstractStringField() {
          @Override
          protected String getConfiguredLabel() {
            return "Field " + param;
          }
        });
      }
    }

    @Order(10.0)
    public class OkButton extends AbstractOkButton {
    }

    @Order(20.0)
    public class CancelButton extends AbstractCancelButton {
    }
 }


Code in my page:
@Order(30.0)
public class GenerateReportWithParametersMenu extends AbstractMenu {

    @Override
    protected String getConfiguredText() {
    return TEXTS.get("ProduceerRapportMetParameters");
    }

    @Override
    protected void execAction() throws ProcessingException {

    Long reportId = getTable().getReportIDColumn().getSelectedValue();
    GenericForm form = new GenericForm(reportId);
    form.setGenericFormNr(reportId);
    form.startModify();
    form.waitFor();
    if (form.isFormStored()) {
        reloadPage();
      }
    }
}
Re: How can I pass additional variables to injectFieldsInternal() [message #1032804 is a reply to message #1032799] Wed, 03 April 2013 13:04 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan MotschFriend
Messages: 154
Registered: March 2010
Senior Member
What is the constructor of GenericForm ?

try the following:


public class GenericForm extends AbstractForm{
 private int m_myParam;

 public GenericForm(int myParam){
  super(false);//false=do not yet initialize the form
  m_myParam=myParam;
  callInitializer();//now init the form, this will inject the fields etc.
 }

 //use m_myParam inside the MainBox inject

}
Re: How can I pass additional variables to injectFieldsInternal() [message #1032812 is a reply to message #1032804] Wed, 03 April 2013 13:15 Go to previous messageGo to next message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
That works perfectly, thank you Ivan.
Re: How can I pass additional variables to injectFieldsInternal() [message #1032916 is a reply to message #1032804] Wed, 03 April 2013 16:02 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan MotschFriend
Messages: 154
Registered: March 2010
Senior Member
did this help?
Re: How can I pass additional variables to injectFieldsInternal() [message #1033702 is a reply to message #1032916] Thu, 04 April 2013 14:41 Go to previous message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
Ivan Motsch wrote on Wed, 03 April 2013 18:02
did this help?


Yes Ivan, it worked perfectly.
Previous Topic:Adding context menus to SVG fields
Next Topic:Maximized form in Swing and SWT
Goto Forum:
  


Current Time: Tue Apr 23 16:05:17 GMT 2024

Powered by FUDForum. Page generated in 0.03388 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top