Showing results for 
Search instead for 
Did you mean: 

Dynamic Event Creation and Handling the events

Former Member
0 Kudos

Hi All

I am using WAS 6.4.

I have two components say Component A and Component B in which Component A is a reusable component and is used by other components say for e.g the Component B.

The following is the requirement.

Component A should create buttons for other components dynamically.

As an example, Component B specifies to Component A the buttons required say button B1 and button B2.

Component B also contains methods M1 and M2 for the buttons created by the component A.

Now I would like to associate these buttons created by component A with the methods created in Component B

The number of buttons that are to be created may vary from component to component.

If any one as any suggestion or solution, help me out.




Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi NagaKishore,

I'm not exactly sure why you want to do this, but it is pretty easy if I switch it up a bit. (Maybe you are trying to create a navigation page or something?)

Instead of your component B using component A, if you define a Web Dynpro interface in component A, then implement this interface in component B (or all component Bs), achieving your goal would not be too difficult. It could define a generic method (or event) with a "button key" as an argument that would tell component B which button was pressed and allow it to behave as desired. The Web Dynpro interface defined in A could also have an interface context that would allow the the button text to be passed along with (for the sake of simplicity) a "button key" that component that should be triggered when the button is pressed. (Note this could be a varying size list as required.)

The component B(s) need not be known until run-time. They can be created using something like:

wdThis.wdGet<Used Compontne Name>ComponentUsage().createComponent(<Component Name>,<Object Name (if in a different component)>)

Once the component is created, the context can be accessed giving the list of buttons to create and the values. The buttons can be created in the wdModifyView during the first pass of the creation of the view displaying the buttons (after the dynamic creation of the used components which can occur in the wdDoInit of the component controller).

If the user presses a chosen button on component A, then the generic method (most likely an event) of component Bs interface is called and passed the "button key", component B then takes over. Note this would also work if component B had a visualization component that must be displayed through an interface view that is defined on the web dynpro component interface that is implemented by B.

Hope this helps or at least triggers discussion that will answer your question,


Former Member
0 Kudos

Hi Gregory Hawkins

The requirement is to build a reusable component which creates buttons up on request by the other components.

Buttons are to be created depending on the user logged in. I have been developing a component where it accepts the request of buttons that are to be created and depending the user who logged in, certain buttons will be created/Displayed to the user.

But the implementation of the methods for the buttons actions are done in the individual components.



Former Member
0 Kudos

If I understand you correctly, you want to wire some methods of component X to the button actions of the reusable component R.

You can't pass methods directly, but perhaps you could pass to component R some callback objects (e.g. implemented as instances of the java.lang.Runnable interface) that call the methods of X.

The button actions could all use the same event handler in R that selects the right callback object from the context and executes it (calls its run() method).

(I did not try this out.)