DCT ~ Help with buttons created through dialog in a replicant container

Hi Everyone,

 

I am facing an issue with buttons created through dialog in a replicant container.  There is a container having multiple items, one such item is a button created through <dialog>, now this container is a replicant and can be replicated to a maximum of 4 times.   For instance, if there are four replicants open and if the user clicks a button in a particular replicant, how will we be able to identify which replicant's button was clicked and which values to be retrieved for processing.  Please suggest.

 

Button 1

<dialog type="button" label="Button1" rowcontinue="t" function="button_subroutine">

<function-param>1</function-param> 

<function-param>.jpeg,.jpg,.gif,.png</function-param>

<function-param>yes</function-param>

</dialog>

Comments

  • Have you tried this out and found a problem with it or are you thinking about it and have not tried it yet?

     

    I believe it should "just do the right thing" as the DCT would know that the button is associated with a particular instance of a field.

     

    If this is not the case, please elaborate / provide additional information 

  • Thanks for replying. The existing DCT does not have replicant containers with buttons. The requirement is to include replicant containers containing multiple sections with text area and buttons. If it were a button in a section outside replicant, we can get the object based on the location of the button; in this case since the button is inside a replicant and user can add upto 4 replicants, I could not figure out which replicant's button was clicked. It is not a mandate to use <dialog> to create button, we can use any other alternate whichever suits better since I am new to Teamsite, I could not figure this out.
    Thanks in advance.
  • The dialog element is, I believe, mostly intended for use with interations with MediaBin (though it is possible it can be used for other things too)

     

    The alternative is to use the callout element with a FormAPI "onCallout" event handler.  When you set up the event handler you provide a simplified path to the item (i.e.: no need to specify replicant instance) - and the function you specified to be called when the event occurs (clicking on the button) will be passed an IWItem object that refers directly to the specific instance that was clicked - so you don't need to do anything extra to determine it.

     

    E.g.:

     

    [DCT]<container name="rep" location="rep" min="1" max="4">
    <item name="field_with_button" pathid="field_with_button">
    <text>
    <callout label="Click Me"/>
    </text>
    </item>
    ...
    </container>

    [FormAPI]function init() {
    ...
    IWEventRegistry.addItemHandler("/root/rep/field_with_button", "onCallout", calloutHandler);
    ...
    }

    function calloutHandler(item) {
    item.setValue(some_function_to_be_called());
    }

     Obviously (hopefully) the above is rather simplified - and "some_function_to_be_called()" could be anything, including something that opens a window to run a CGI program or you could be doing a callServer to run a non-interactive program on the server, etc.  

     

    The point is that you don't have to worry about whether it is instance-1 or instance-2 (etc.) of the replicant - the function you call when that event is triggered automatically gets the item associated with the "right" instance.

     

    Hope that helps.

Sign In or Register to comment.