cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action

Former Member
0 Kudos

Hi,

I want to make a method that takes a TransparentContainer as an input and populates it with UI Controls.

The method resides in the Component Controller and is exposed to other components.

One of the component is a Button. How can I make a custom Action (IWDAction) in order to register my event handler with setOnChange()? Can someone provide me with an example?

Thank you,

Pietro

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

Thank you Radhika.

I've seen the links you provided me but I can't still figure out how to create an event handler.

I'm in the Component Controller (not in the View Controller) and so I don't have the Actions tab. How can I create a WDActionEventHandler in order to create the action with IWDAction buttonAction = wdThis.wdCreateAction(???, text);

Thank you,

Pietro

Former Member
0 Kudos

Hi Pietro,

First of all whatever dynamic code you write is always inside wdModifyView() method.

It is not present in the component controller. So, you will have to write dynamic UI element creation code insde View controller only.

Regards,

Radhika

Former Member
0 Kudos

Hello,

Click on the metods tab of the component controller and click on the new button then you will be asked for creating an Even handler.

For creating or manipulation of UI we need the view reference which is only present in the wdDoModify View

SAP Doest recommend to change the view in any other method.

But if there is a requiremnt you can pass the referece of view from wdDoModigy view to the contect variable of type IWDView and use this variable in any method.

Regards,

Raju Bonagiri

Former Member
0 Kudos

I have created an event handler like you said but it does not show up when I write:

	  IWDAction buttonAction = wdThis.wdCreateAction(
			  IPrivateAdvancedSearch.WDActionEventHandler.???, 
			  "TestAction");

In other words, I can't find the WDActionEventHandler instance created in IPrivate(ComponentName).WDActionEventHandler.(WDActionEventHandlerInstance).

The only thing that I can find is IPrivateAdvancedSearch.WD_EVENTHANDLER_HANDLER_ON_ACTION_BUTTON that is an IWDEventHandlerId.

Thank you,

Pietro

gill367
Active Contributor
0 Kudos

Hello,

I am not clear with the requirement. But if you want to create the UI element on click of a button,

you can achieve the same by writing some code in the wd domodifly method of the view controller and put a validation before executing the code like as shown below

wddomodify()
{
if(compare some element for a particular value)
{
create the UI elements here
}
}

then create the button and its action. in the event handler of the action set the value to desired one.

so that code in the wddomodify can execute and create the elemenet

remember that on every event in the view wddomodify method is called.

Thanks

Sarbjeet Singh

Former Member
0 Kudos

Hi Sarbjeet,

what I'm trying to do is this:

I have two components, the Client and the Server. The Client, in order to use Server's services, has to place some specific UI in its view. So I'm writing a method in the Server that receives a TransparentContainer from the Client: in this method the Server creates the UI components, binds them with the Client context -- passed also as a parameter, and binds the controls with the appropriate event handlers.

So the Client doesn't have to clutter his view but has only to have a TransparentContainer as a placeholder to be filled by the Server's method (this is done to avoid code repetition because the Client can host in a single view a lot of those UI pieces).

I hope this makes things clear.

See you,

Pietro

Former Member
0 Kudos

Hi Pietro,

As per my observation, when you create event handler by going to the methods tab, then that event handler does not show up in the list of event handlers (the problem which you are facing right now).

One reason might be that createAction() method requires the evnt handler corresponding to an action.

So what you can do is you can create an action in your view and the corresponding event handler will be automatically added to your Methods tab. Then, you can see this newly created event handler in the list for createAction(IPrivate<viewname>.wdEventHandler.<eventhandler>)

Regards,

radhika

Former Member
0 Kudos

Hi,

Basically you want call a function on the Server component and create the UI elements in a view of the Server and return back the re-loaded TransparentContainer from the component to the controller of the Server. Hope I am clear with your requirment.

Then create an event in the Controller of the Server, lets say - FireUIEvent. Go to the methods tab in the view, select new and choose event handler, give some name. Select event source as your component(server) and then subscribed event as - FireUIEvent.

Now in the method where you get the TransparentContainer as parameter you fire this event and pass the TC.

Use - wdThis.wdFireEventFireUIEvent(); // Add parameter to the event of type TransparentContainer.

Add UI elements in the view accroding to your logic, map the attributes to the UI elements and then return it.

Hope it helps.

Regards,

Manoj

Former Member
0 Kudos

Hi Manoj,

thank you for your reply, but it's not the scenario I'm working on. Let's see if I can be more clear...

Things should work like this:

1. Client has an empty Transparent Container embedded in one of his view (ClientView)

2. Client, from his view, calls the Server's method. Server's method is placed in the Server's Component Controller. (...getServerController().setupClientView(clientTransparentContainer, clientContext))

3. The Server's method creates the UI Component using ClientView's View Root Container

PARAMETER IWDTransparentContainer view ===========

IWDView rootView = view.getView();

IWDImage image = rootView.createElement(
	  IWDImage.class, idPrefix + "Image");
IWDButton button = rootView.createElement(
	  IWDButton.class, idPrefix + "Button");

4. The Server's method add the UI components to the Client's TransparentContainer

view.addChild(image);
 view.addChild(button);

5. When the Server's method ends and the flow of control goes back to the Client, the TransparentContainer in the Client's view is populated with the UI widgets.

Currently, "everything" works (the widgets are properly created and displayed), but I can't figure out how to create and bind the event handlers during the creation process that takes place in the Server's method. No view from the Server should be displayed during this operation: that's why the Server's method is placed in Server's Component Controller.

Thank you,

Pietro

Edited by: pietro.m on Sep 28, 2010 2:18 PM

Answers (1)

Answers (1)

Former Member
0 Kudos

Unanswered question: closed due to inactivity