Skip to Content
author's profile photo Former Member
Former Member

How to get a CheckboxEvent

Hi all,

I use an AbstractPortalComponent. In the doContent-method I build up a Tree containing TreeNodes that carry Checkboxes. Can anyone explain to me how I can get the events which are fired by the checkboxes. See my example:

public class ObjectTree extends AbstractPortalComponent

{

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

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

Form form = context.createFormDocument("Test");

context.render();

FormLayout formLayout = new FormLayout();

Tree tree = new Tree("new Tree");

TreeNode rootNode = new TreeNode("root", "Wurzelobjekt");

tree.setRootNode(rootNode);

rootNode.setComponent(createCheckbox("Wurzelobjekt"));

TreeNode treeNode1 = new TreeNode("zwei", "zweite Ebene", rootNode);

treeNode1.setComponent(createCheckbox("zweite Ebene"));

TreeNode treeNode2 = new TreeNode("drei", "dritte Ebene", treeNode1);

treeNode2.setComponent(createCheckbox("dritte Ebene"));

formLayout.addComponent(1,1, tree);

form.addComponent(formLayout);

context.render();

}

private Checkbox createCheckbox(String name)

{

Checkbox cb = new Checkbox(name);

cb.setText(name);

cb.setOnClick("click");

return cb;

}

public void click(Event event)

{

System.out.println("TreeView onClick");

}

The click-method ist not executed.

Thanks in advance

Martina

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2005 at 01:25 PM

    Hi Detlev,

    I've just removed the first render() but it still doesn't work. The click-method seems not to be executed. You have another idea?

    Thanks and kind regards

    Martina

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Martina,

      oh, sorry. At least, the effect of deleting the line was a server roundtrip. So a step into the right direction 😊

      OK, I have been totally irritated by your example... The solution... here it comes...

      AbstractPortalComponents are "so poor" that you have to care about the events by yourself. So you have to catch the event and pass it to the right method.

      See https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/basics of java iview development page 21/22

      and the cite from PDK -- Java Development -- Documentation -- Getting Started -- Creating a Portal Component -- Implementing a Portal Component -- AbstractPortalComponent Using HTMLB:

      <i>Event Handling

      Using HTMLB within an AbstractPortalComponent you are responsible for event dispatching yourself. You will get the current event form PageContext:

      Event lastEvent = myContext.getCurrentEvent();

      Using this event object you must dispatch the event to your event handler methods.</i>

      Hope it helps

      Detlev

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2005 at 12:48 PM

    Hi Martina,

    in click-method of the button:

    Checkbox myCheckbox = (Checkbox) getComponentByName("myCheckbox");

    boolean isChecked = myCheckbox.isChecked();

    Regards,

    Gerhard

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Gerhard, hi Martina,

      @Gerhard: Martina's problem wasn't how to get infos about the event, but the method hasn't been called anyway!

      @Martina: Just delete the superfluous first "context.render();" and everything is working fine.

      Hope it helps (it will)

      Detlev

      PS: Please consider awarding points for helpful answers, just by pressing the yellow star button on the reply in question and choosing the corresponding amount of points. Thanks in advance!

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2005 at 03:01 PM

    Detlev,

    thanks, problem is solved.

    That was sort of "tomatos on my eyes"-problem.

    Martina

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.