Multiple selection in Custom Dialog in D2

Mayur_shivs
edited April 29, 2016 in Documentum #1

Hi Experts,

We have developed a custom Dialog in D2.

Currently this dialog only works on single selection, means even if there is multi selection in document List widget. We are getting only one r_object_id in our buildDialog() method.


public XmlNode buildDialog(D2fsContext context, List attributes)
  throws Exception {


  XmlNode result = null;

  System.out.println("Inside BuidlDialog Method Of CustomDialogPlugin");

  ParameterParser parameterParser = context.getParameterParser();

  List<Attribute> params = parameterParser.getParameters();

  for(Attribute attribute : params) {

  LOG.info("Attribute Name : " + attribute.getName() + "   Attribute Value : " + attribute.getValue());
  }

  if(attributes != null) {
  for(Object attr : attributes) {

  Attribute at = (Attribute) attr;

  LOG.info("Attribute Name 1) : " + at.getName() + "   Attribute Value 1) : " + at.getValue());
  }
  }

  int count = context.getObjectCount();

  LOG.info("Number Of Objects Selected : " + count);


  java.net.URL dialogFile = context.getXmlDialogFile();


  LOG.info("XML Dialog File : "  +  dialogFile.getPath(
}));


We get following information in Logs

Attribute Name : id   Attribute Value : 09*******003679f

Number Of Objects Selected : 1

Question : How can we fetch r_object_id value for other selected documents in Document List widget.

Observation : The In build Dialog in D2 implements Managers Like

Send Mail ----> Show dialog with manager :"SendmailManager"

This dialog uses SendmailManager class which resides under WEB-INF\classes\com\emc\x3\portal\client\manager\sendmail  in D2 Application.

We also tried to create The manager class like this





}



public class AgendaManager extends AbstractActionManager






{


  protected static final Logger LOG = LoggerFactory.getLogger(AgendaManager.class.getName());
  public List<String> listIds;


  public AgendaManager(OpenAjaxMessage message) {
  super(message);


  }


  @Override
  public void handleAction() {
  LOG.info("AgendaManager");
  List<String> ids = initListIds();
  for (String strid:listIds)
  {
  LOG.info("ListIDS element: "+strid);
  }

  StringBuilder builder = new StringBuilder();

  Iterator<String> it = ids.iterator();

  while(it.hasNext()) {

  String s = it.next();

  builder.append(s);

  LOG.info("IDS : " + s);
  }

  String idfIDs = builder.toString();


  List<Attribute> attributes = new ArrayList();


  getDialogController().showDialog(idfIDs, "AgendaDialog", attributes);




  }






  private List<String> initListIds()
  {
  listIds = new ArrayList();
  String ids[] = getMessage().getIds();
  for(int i = 0; i < ids.length; i++)
  listIds.add(ids[i]);

  return listIds;


  }


}


currently we have created custom menu and specified "Show Dialog "AgendaDialog". In logs we are getting single r_object_id on multiple selection.

We are specifying this manager in custom menu in D2-Config, But it seems that custom manager class is not getting invoked at all.

Do we need to register this class somewhere in D2 , How should we enable mutiple selection in D2 Dialog.

Regards

Mayur Mitkari

Comments

  • Francois Dauberlieu
    edited January 25, 2016 #2

    I guess you could try something like that. I use it in a custom dialog action....

        for (int i = 0; i < context.getObjectCount(); i++)
       {
       final IDfSysObject obj = (IDfSysObject) _context.getObject(i);

         // Do your stuff here

       }
  • Mayur_shivs
    edited January 25, 2016 #3

    Hi ,

    Thanks for the reply.

    But I am getting value for context.getObjectCount() as one , which i have logged also in above code.

    No matter how many object i select in doclist widget, i always get 1 as object count in the logs.

    Regards

    Mayur Mitkari

  • Francois Dauberlieu
    edited January 25, 2016 #4

    Not in front of a proper machine so I can;t check but if my memory serves me well, when you define your action to launch the dialog (thru a menu at least) you can define if it's a single or multiple select action with setting the eMode to MONO or MULTI...

  • Mayur_shivs
    edited January 25, 2016 #5

    Hi

    I have deployed this as Dialog.

    In D2-Config i have selected menu item option as " Show Dialog "AgendaDialog" "

    In D2/WEB-INF/lib i have specified plugin JAR.

    For Dialog i haven't used any action.

    Do i need to change something, in order to get this working for multiple selection ?

    Regards

    Mayur Mitkari

  • Antal Bos
    edited January 25, 2016 #6

    Hi Mayur,

    It's a very specific question you ask and takes some time to reproduce.

    Time I don't have at the moment, but maybe this information can help you with the problem.

    When I select a second document (with <Ctrl>/<Shift>) I only see the D2MenuService beeing triggered.

    I extended the D2MenuService with my custom plugin and then I see all the selected r_object_id's passing by. See the log sample:

    D2MenuServicePlugin[                    ] : START getFullMenusContent()

    D2MenuServicePlugin[                    ] : id: 0902XXc6811ae564¬0902XXc6811ae55a

    D2MenuServicePlugin[                    ] : type: MenuPortal

    D2MenuServicePlugin[                    ] : Format: null

    ...

    D2MenuServicePlugin[                    ] : END getFullMenusContent()

    When I have some more time I will check again.

    Best regards,

    Antal

  • Antal Bos
    edited January 25, 2016 #7

    End indeed check this option in your menu configuration:

    Untitled.png

    Best regards,

    Antal

  • Antal Bos
    edited January 25, 2016 #8

    I did i quick second test:

    When I set the option above from SINGLE to MULTI this is my log output with in the end the 2 selected objects ID's:

    D2CustomService[                    ] : START getCustomDownloadURL

    D2CustomService[                    ] : URL: http://localhost:8080/D2/servlet/ExportContent?uid=MY_REPO-1453733819028&_docbase=MY_REPO&_username=dmadmin&_password=DM_TICKET%3DTXX&_locale=en&exportType=custom&contentType=custom&colType=custom&custom_call=true&id=0902XXc6811ae55a-0902XXc6811ae564

    D2CustomService[                    ] : END getCustomDownloadURL

    Best regards,

    Antal

  • Mayur_shivs
    edited January 26, 2016 #9

    Hi ,

    Thanks for the reply.

    What I understood from your explanation is that, I should write my own custom service in this case and Launch Dialog from custom service, is it correct ?

    Regards

    Mayur Mitkari

  • Antal Bos
    edited January 26, 2016 #10

    Hi,

    As Francois described you need to pass the eMode==MULTI parameter in your message call.

    So weather it's an action that calls a custom service, publishes an event or shows a dialog does not matter. Make sure you pass the parameter in the message.

    If this is done correctly you can see in the HUB widget. This is the message from above samples in the D2 HUB widget:

    #2 [D2_ACTION_EXECUTE] rType==EVENT!!rAction==D2_ACTION_EXPORT_FROM_URL!!eMode==MULTI!!eMethod==getCustomDownloadURL!!CHANNEL_EVENT==D2_ACTION_EXECUTE!!eService==D2CustomService!!oam_sender==MenuWidget!!oam_cuid==MY_REPO-1453805448734-dmadmin

    Best regards,

    Antal

  • Mayur_shivs
    edited January 27, 2016 #11

    Hi ,

    Is there any way to launch custom dialog from custom action, If there is any way please let me know.

    Regards

    Mayur

  • Antal Bos
    edited February 11, 2016 #12

    Hi,

    Sorry for the late response, but it took some time to check out your question with limited spare time.

    Yes, it is possible; Here's how:

    1. Create a custom menu item
      1. Action: 'Show dialog'
      2. Dialog: 'D2MyDialog'
    2. Create a D2 plugin and add a custom class in the src-folder called 'D2MyDialog.java'
      1. See below the sample java code
    3. In the D2 plugin also add a custom xml in the resources folder called 'D2MyDialog.xml'
      1. See below the sample xml

    JAVA-CODE SAMPLE

    public class D2MyDialog extends AbstractDialog implements ID2Dialog {

      @Override

      public XmlNode buildDialog(D2fsContext context, List<Attribute> attributes) throws Exception {

      D2fsContext d2fsContext = (D2fsContext) context;

      IDfSession session = d2fsContext.getSession();

      XmlNode result = super.buildDialog(context, attributes);

      //Do your custom thing on the XML content.

      return result;

      }

    }

    XML SAMPLE

    <?xml version="1.0" encoding="utf-8"?>

    <dialog id="CommentDialog" focus="editor" width="640" height="450" resizable="true" buttons="bottom">

      <content>

      <html-editor id="editor" required="true" label="" height="100%"/>

      </content>

      <buttons>

      <button id="buttonOk" condition_enabled="false" type="submit" action="validDialog()"/>

      <button id="buttonCancel" type="reset" action="cancelDialog()" />

      </buttons>

    </dialog>

  • Zgardan
    edited February 11, 2016 #13

    Hi,

    Have you found how to register a custom Manager class ?

    Thx.

  • Antal Bos
    edited February 12, 2016 #14

    I didn't try it out, but i also see an action called: 'Show dialog with manager : "$value(manager)"'

    Then add the custom manager class name in the Manager field: e.g. CustomActionManager that is part of the plugin.


    As far as I know you don't need some kind of 'register' action. D2 will pick it up automatically from the plugin.

    Hope that will help,

    Antal

  • Mayur_shivs
    edited February 13, 2016 #15

    Hi Antal,

    Thanks for the reply.

    I already implemented the Dialog in similar way also i have put the print statements in buildDialog() method but the problem with this approach is that you will get only first selected object from context.

    But the challenge is to get multiple object Ids on multiple selection with this implementation.

    I also added Manager class as posted in original comment, but D2 does not detect it at all. It does not gets picked up automatically.

    Regards

    Mayur Mitkari

  • Mayur_shivs
    edited February 16, 2016 #16

    Hi Experts  ,

    One more question to this is :

    In valid Dialog after all operations i am showing success message , with following code.


    XmlNode xmlNode = null;

    xmlNode = XmlFactory.getRootSuccess();

    xmlNode.setAttribute("title", "Agenda document creation successful");

    xmlNode.setAttribute("message", "Agenda document '" + agendaRegistrationNumber + "' created successfully inside Agenda document folder");

    return xmlNode;



    With above code i am able to show the success message. But the problem here which i am facing is : on click of OK in success message my dialog screen is still visible. By default it should be "hidden" when i click "OK".

    Below are the console messages in browser when i click on OK.


    14:27:30.213 INFO DialogWidget : PUBLISH :  - event : D2_EVENT_DIALOG_HIDE  - message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.window.X3Window - oahub client : 148
    14:27:30.242 FINE FocusWidget : Storing message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.window.X3Window - oahub client :322
    14:27:45.409 INFO DialogWidget : PUBLISH :  - event : D2_EVENT_DIALOG_HIDE  - message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.dialog.builder.MessageFactory - oahub client : 148
    14:27:45.412 FINE FocusWidget : Storing message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.dialog.builder.MessageFactory - oahub client : 322








    In case of success messages launched from D2 in build dialog like D2 Workflow Launch Dialog. On click of "Ok" in this case we get following console messages.


    14:20:07.831 INFO DialogWidget : PUBLISH :  - event : D2_EVENT_DIALOG_HIDE  - message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.window.X3Window - oahub client : 148
    FocusWidget : Storing message : oam_cuid==TestDocbase8-!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.window.X3Window - oahub client : 322
    FluidContainer : setScrollMode set scroll to AUTO
    INFO DialogWidget : PUBLISH :  - event : D2_EVENT_DIALOG_HIDE  - message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.portal.client.components.dialog.DialogView - oahub client : 148
    FINE FocusWidget : Storing message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.portal.client.components.dialog.DialogView - oahub client : 322
    INFO DialogWidget : PUBLISH :  - event : D2_EVENT_DIALOG_HIDE  - message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.dialog.builder.MessageFactory - oahub client : 148
    FINE FocusWidget : Storing message : oam_cuid==TestDocbase8!!oam_sender==DialogWidget!!oam_global==true!!oam_classname==com.emc.x3.client.dialog.builder.MessageFactory - oahub client : 322





    So the basic difference between these two is, case of custom dialog success message following events are not fired.   "D2_EVENT_DIALOG_HIDE"  "oam_classname==com.emc.x3.portal.client.components.dialog.DialogView" is not passed in event message.

    What will be the solution in order to hide the custom dialog on click of "Ok" in success message.

    Regards

    Mayur Mitkari

  • @mat
    edited April 29, 2016 #17

    Hi,

    I don't think it'a a good way to do it, but you can send your message by throwing a D2 Exception, it will be hidden when closed by client.

    but maybe you find how to add an event to be fired ?

    I'm trying to create a new dialog (this is ok) but i need to refresh the widget after. And i don't understand how to do that.

    Also tried with managers, but unable to make D2 take it into account...

  • Anyone was successful with multi select using custom dialog? If yes, please share the solution.

  • Finally got a solution to this problem from OpenText. In the triggering menu item, add raw==true in the message field, This will allow the dialog context to get all the objects selected.

  • works like a charm! thanks!