Skip to Content
avatar image
Former Member

Button parameter mapping for tree tables (nw04)

I've successfully implemented a table including a master column, which is bound to a context tree node. The table has property selectionMode: none

Next to the master column I have a couple of columns, one containing a button. This button has property onAction: ShowInfo.

In the corresponding method 'onActionShowInfo' I want to show a dialog containing information belong to the row of the pressed button. How can I obtain some kind of reference to the corresponding row of the clicked button?

Grtz,

Chris

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    May 26, 2009 at 01:01 PM

    @ Charan,

    I tried all three references, none work. I've put it back to the most obvious, which is the private one, as that one is used for the master column

    @ Armin,

    I created a new action, including the correct parameter. No warnings so far. As soon as I set the onAction attribute to this new action, I get these warnings.

    Should I not set the onAction attribute in design time?

    grtz,

    Chris

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Ok, I see. I thought the warning occurs only after mapping the event parameter. However, forget the warning, it is completely useless. You should use the IDE to assign the action and also the Parameter Mapping editor (if available in your version, check context menu in Outline view).

      The action parameter should either be of type IWDNodeElement (and you can cast it yourself inside the action handler) or of type IPrivate<ViewController>.I<Node>Element.

      Armin

  • avatar image
    Former Member
    May 26, 2009 at 11:38 AM

    Hi,

    Do the source mapping in wdDoModifyView as below to the button UI element you created in second column.

    IWDButton button = (IWDButton) view.getElement("Button");
    button.mappingOfOnAction().addSourceMapping("nodeElement", "element");

    Note: Here "Button" is the Id of the Button UI element.

    After this for example you binded "TestValuesNode" to the table (which is having master column) then for 'onActionShowInfo' action add that node element as arguement with arguement name as "element" (this is must - bcause we did the source mapping with the name "element" ) as below.

    public void onActionShowInfo (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, IPrivateTestView.ITestValuesNodeElement element )
      {
        //@@begin onActionViewProposalDetails(ServerEvent)
      
          wdComponentAPI.getMessageManager().reportSuccess(element.getValue());
        
        //@@end
      }

    Regards,

    Charan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 26, 2009 at 01:20 PM

    Armin & Charan,

    Thanks for your time and input! I have got it working now, thanks to your help.

    The last problem was I had a typo (towards another button) in the view.getElement call.... whoops.

    Anyway, I've got it working now, though it is a bit of a shame of the warnings (I tend to minimize warnings in order to detect useful warnings more easily)

    Again, thanks! Points are on their way 😉

    Grtz,

    Chris

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Your are right about the useless warnings. In fact I have reported this issue already some time ago internally. Maybe you want to open another OSS message (BC-DWB-WD-JAV).

      Armin

  • avatar image
    Former Member
    May 26, 2009 at 11:58 AM

    Hi Charan

    Thanks for your quick reply.

    Unfortunately I get a warnings in developer studio and a null pointer as resulting element in runtime. The warnings are:

    UIElementEventBinding onAction: Parameter element(iTestValuesNodeElement) cannot be supplied

    Button ButtonShowInfo [onAction]: Action and event are not compatible

    What am I missing here?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      How did you select the parameter to the onActionShowInfo action.

      Check you followed the below procedure exactly.

      1. Go to the actions tab in your view

      2. select the onActionShowInfo

      3. Go to the parameters secion and select new

      4. Enter the name as "element" && Select the lookup beside type

      5. Select Java native type radio button.

      6. Select browse

      7. Now search for ITestValuesNodeElement and select this one

      Note: The name of this parameter must be "element" only. Because we have mapped the element with this name in wdModifyView() method.

      Regards,

      Charan

  • avatar image
    Former Member
    May 26, 2009 at 12:28 PM

    Hi Charan,

    That is exactly what I did, but I still get the same error. I'm probably missing something trivial.

    As soon as I add the parameter 'element' to the action, I get the two warnings.

    I'm assuming that the type of element can somehow not be resolved. When I search for the treeNodeElement I find 3 references. One private, one from the originating custom controller and some other controller. I tried both the private one and the originating.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Strange. You should get these (useless) warnings only when you define the parameter mapping using the "Parameter Mapping editor", not when you define it by code.

      Armin