Announcement Announcement Module
Collapse
No announcement yet.
Dynamic form? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic form?

    Hi,

    I would like to create a dynamic form.

    Code:
    Object[] objs = new Object[] { "string", 50, 30.0 };
    I would like to create a form like this:
    Code:
    arg0: [_______string]
    arg1: [_________50]
    arg2: [__________30]
    Does anyone have a hint how to realize this?

    I tried the following:

    Code:
    public class ParamModel {
    	private Object[] args;
    	public ParamModel() {
    	}
    	public Object[] getArgs() {
    		return args;
    	}
    	public void setArgs(Object[] args) {
    		this.args = args;
    	}
    }
    Code:
    ParamModel pm = new ParamModel();
    pm.setArgs(...);
    MyForm form = new MyForm(FormModelHelper.createFormModel(pm));
    ...
    When i try to do the binding with property name "arg[0]" i get the following exception:
    Code:
    InvalidPropertyException: Invalid property 'args[0]' of bean class [de.netzprofis.crud.client.swing.rcp.ParamModel]: No property 'args[0]' found
    org.springframework.beans.BeanWrapperImpl.getPropertyDescriptor(BeanWrapperImpl.java:254)
    org.springframework.binding.support.BeanPropertyAccessStrategy$BeanPropertyMetaAspectAccessor.getPropertyType(BeanPropertyAccessStrategy.java:366)
    org.springframework.binding.form.support.AbstractFormModel.add(AbstractFormModel.java:378)
    org.springframework.binding.form.support.AbstractFormModel.add(AbstractFormModel.java:359)
    org.springframework.binding.form.support.AbstractFormModel.getFieldMetadata(AbstractFormModel.java:424)
    org.springframework.richclient.form.binding.support.AbstractBinderSelectionStrategy.getPropertyType(AbstractBinderSelectionStrategy.java:281)
    org.springframework.richclient.form.binding.support.AbstractBinderSelectionStrategy.selectBinder(AbstractBinderSelectionStrategy.java:69)
    org.springframework.richclient.form.binding.support.AbstractBindingFactory.createBinding(AbstractBindingFactory.java:68)
    de.....rcp.EntityForm.createFormControl(EntityForm.java:113)
    ...
    Any hints? please help...!

  • #2
    You need to provide your own implementation of MutablePropertyAccessStrategy interface. See BeanPropertyAccessStrategy for an example.

    Afterwards, you need to pass that strategy to DefaultFormModel constructor, and use that form model for your form.

    Andrius

    Comment

    Working...
    X