cancel
Showing results for 
Search instead for 
Did you mean: 

Event Handling in Abstract Portal Component

Former Member
0 Kudos
60

Hi Friends,

I am using HTMLB Classlib in an Abstract Portal Component to develop a Dropdownlistbox. Now I want to handle the event of change of selection in this dropdown. However, this event is not getting captured. Sample code is as follows:

public class dropdownsimple extends AbstractPortalComponent

{

public void onClick(Event event)

{

}

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

IPageContext myContext1 = PageContextFactory.createPageContext(request, response);

Form myForm = myContext1.createFormDocument("CRMForm");

GridLayout myGrid = new GridLayout();

DropdownListBox drp = new DropdownListBox("drp");

drp.addItem("Key 1","Item 1");

drp.addItem("Key 2","Item 2");

drp.setOnSelect("onClick");

myGrid.addComponent(1, 1, drp);

myForm.addComponent(myGrid);

myContext1.render();

}

}

I am able to see the dropdown box along with values when I preview the PAR iView created from this component. Please let me know how to capture the event of change of selection in the dropdown?

Edited by: Shetul Chothani on Jun 21, 2011 6:37 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

Hi,

Change this line

drp.setOnSelect("onClick");

to

drp.setOnSelect("click");

and leave the line

public void onClick(Event event)

as it is, and it should work just fine.

I.e., if you name your event "fooBar", the event handler should be named "onFooBar"

Cheers,

Robin

Former Member
0 Kudos

Hi Robin,

Thank you for the reply... However, this is not working... The behavior of the component is the same... To give you more details, when I change the selection of the value in the dropdown, (say from Item 1 to Item 2), it sets back to Item 1. Moreover, I use Logging to make sure it goes into the Eventing method, but the logger is not getting printed which shows that the eventing method is not getting called.

public void onClick(Event event)

{

tempValue = "Inside onClick Method...";

searchLogger.infoT("Inside Eventing...");

}

I appreciate your thoughts...

Shetul

Qualiture
Active Contributor
0 Kudos

Hi,

First, the problem is you haven't bind the dropdownbox to a model. I.e. when the onSelect event occurs, the page will get reloaded and rebuilt, without saving the dropdown state. I recommend using a (JSP)DynPage with a bean class.

Second, I would recommend using a DynPage / JSPDynPage since this is intended for HTMLB use. This way, your event has to work

Best,

Robin

Former Member
0 Kudos

Hi Robin,

The requirement demands the usage of only Abstract Portal Component as there is already an existing code on which I have to build.

Could you please elaborate on binding the Dropdownlist with the model? I am new to HTMLB and so I would appreciate it very much if you could provide me with some sample piece of code.

Regards,

Shetul

Qualiture
Active Contributor
0 Kudos

Have a look at

Hope it helps,

Robin