Loading existing frame but modify it when init.

For example, we take “sample-sales”, we want to add a button to customer editor, for adding orders directly.

  1. Originally, the order editor has a lookupField that let you chose a corresponding customer.
  2. Since the workflow is first editing a customer, then add a order to that customer, so implicitly the customer is designated.
  3. Thus, we don’t have to re-assign a customer to that order.

Here, we need to:

  1. Keep the original order editor untouched if we open it from menu.
  2. Invisible or remove customer lookupField and assign customer to that order automatically if we open the order editor from customer editor.
  3. Suppose the customer editor has a frame that pointed to order browser instead of manually added table and buttons, do we have a way to keep the original screen, but modify it a bit when it loaded by as a frame by different screen?

There is setWindowParams() method in standard Create/Edit actions. Use this method for “static” parameters that can be determined at screen init time. For passing “dynamic” parameters, you have to create your own subclass of a standard action and override getWindowParams() method. It will be invoked when the action is executed.

Actually, there are few decomposed questions:

  1. If you open a EntityB editor (dialog mode) in EntityA editor to create a new Entity B that has a many-to-one relation to EntityA, how do you know which EntityA is picked in EntityB’s controller?
  2. What if EntityA is not an existing one but a new one under creating?
  1. Pass parameters in the map when invoking openWindow() or openEditor(). Then you can use the parameter values in the init() method of the invoked screen. You can also inject parameters as shown here. In the init() method, you can programmatically set up your screen components.

  2. Probably you shouldn’t allow a user to open EntityB editor until EntityA is saved. You can use windowActions frame with extended flag (whis is actually a extendedEditWindowActions frame in XML) to automatically display three buttons on the EntityA editor: OK & Close, OK, Close. Then use postInit() method to enable/disable the component invoking EntityB editor depending on the value of PersistenceHelper.isNew(entityA).

  1. If we use standard action like create/edit, it does not rise a literal

, how do we know which screen is the parent/caller of it? I’ve examined








, but none of them revealed the hint.
2. I used composition to accomplish the goal, and thanks for the mention to


, the


in the


also tells you wether it has a


or not.

Thank you, finally it’s done by


in caller, then check the params in callee, then we can know who’s calling it and further instructions.