0

I'd like to add a list of strings to a Dialog list with an Java agent. Item's value changes but it doesn't show the values on form.

Session session = getSession(); 
AgentContext agentContext = session.getAgentContext();
Database db=session.getCurrentDatabase();
Form form = db.getForm("UOs_AD");
Document document = agentContext.getDocumentContext();
Item item = document.getFirstItem("UO_AD");
Vector v = new Vector();
v.addElement("Bicycle");
v.addElement("Train");
v.addElement("Foot");
Item textListItem = document.replaceItemValue("UO_AD", null);
textListItem.setValues(v);
textListItem.setSummary(true);
document.save(true, true);
  • Please specify, why you want to do a change to the design of a form via an agent, dxl, ... and not via the Domino Designer (which would be a 30 seconds task). – leyrer Sep 01 '13 at 20:19
  • I have function to get "OU" as List from Ldap server and i won't to show the result oh this Dialog list – user2359024 Sep 02 '13 at 07:48

3 Answers3

2

I'm not sure that I understand your question. Are you trying to update the Form so that "Bicycle", "Train" and "Foot" will be choices in the dialog list whenever someone creates or edits a document? Or are you trying to update a specific document so that these three values are selected for the field value? Your code appears to be updating the Document.

If you are just trying to get those three values to appear as selected, then make sure that your field has the "Allow values not in list" property selected in Domino Designer. Also, make sure that the "Allow multiple values" property is selected.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • i have an empty Dialog list and I wont to show "Bicycle" , "Train" and "Foot" on this list via java agent – user2359024 Sep 01 '13 at 11:53
  • Have you considered using the 'Use formula for choices' feature for the dialog list? Your agent could populate an item in a profile document, and the formula for the choices list could use @GetProfileField() to retrieve those values. – Richard Schwartz Sep 01 '13 at 13:56
1

replaceItemValue() only replaces the value of a field in the current document (which you got via agentContext.getDocumentContext()) and not the choices that, for example, a Combobox tied to that field offers the user.

If the choices a Combobox offers are static you need to use Domino Designer to open the form the document is based on and change the values offered for the choices in that field. If you want to do that programmatically, you would have to work with DXL.

leyrer
  • 1,444
  • 7
  • 9
  • 1
    Your first link points to XPages ComboBox but should point to a description of `Dialog list` like [this](http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_GENERATING_CHOICES_FOR_LISTS_STEPS.html&resultof=%22dialog%22%20%22list%22%20%22choices%22%20%22choic%22%20) – Knut Herrmann Aug 30 '13 at 14:37
  • i have an empty Dialog list and I wont to show "Bicycle" , "Train" and "Foot" on this list via java agent, i need an example with DXL – user2359024 Sep 01 '13 at 11:52
  • Why not just change the Dialog List element with the designer client? This is a lot faster then using DXL to change the design element. DXL examples can be found via Google. – leyrer Sep 01 '13 at 20:18
  • I have function to get "OU" from Ldap server and i won't to show the result oh this Dialog list – user2359024 Sep 01 '13 at 21:06
0

OK, so based on your latest feedback, your question really should have been:

How can I display the result of an LDAP query (in my case a list of OUs), done with some Java code, in a IBM Notes Dialog List?

You are out of luck with "classic" Domino Designer. A classic notes form only offers you (either via the Designer, but also via DXL) the following options for a dialog list:

  • Enter choices (one per line): Type a list of choices in the edit box.
  • Use formula for choices: Type a Lotus Notes formula in the formula window to generate a list of choices.
  • Use Address dialog for choices: This option displays the Names dialog box so users can select names from a Personal Address Book or Domino Directory.
  • Use Access Control list for choices: This option brings up a list of people, servers, groups, and roles in the access control list for the database
  • Use View dialog for choices: This option brings up a dialog box containing entries from a column in a view

So no way of adding the output of some Java code to the Dialog List.

What you can do is:

  1. Use XPages. With XPages, you can have Java code to fill any kind of List, Dialog Box, ...
  2. Use your Java code in a scheduled Notes Agent to "sync" the LDAP entries into the Notes database by creating notes documents, eg. "OU" which represent the LDAP entries. Using a View, you could then use the "Use View dialog for choices" option of the Dialog List to display them to the user.
  3. Use TDI (entitlement for this comes with Domino) to sync the LDAP entries into the Notes database by creating notes documents, eg. "OU" which represent the LDAP entries. Using a View, you could then use the "Use View dialog for choices" option of the Dialog List to display them to the user.
  4. Use your Java code in a scheduled Notes Agent to update a field inside a profile document with the list of "OUs". Then use a @-formula to display the values in the Dialog List.

Solution (2), (3) and (4) have the disadvantage of not displaying "realtime" info of the LDAP directory.

I hope I understood your problem correctly. If so, please edit content and title of your question acccordingly.

leyrer
  • 1,444
  • 7
  • 9
  • Sorry to say: I don't agree... Create a field "MyListChoices", computed (for display), multi value, formula: @ThisValue. Then select "use formula" in the dialog field and as a formula use the fieldname "MyListChoices" (without the ""). Now you just have to fill the field MyListChoices with the result of your code and refresh the doc - voila – Tode Sep 02 '13 at 16:30
  • Thorsten, no need to apologize. ;) BUT: You would use a periodic Java Agent to add a field to every document containing a list of the OUs and update all documents every time the agents runs and/or the list of OUs changes? To me, that seems rather inefficient. But storing the OUs in a field inside a profile document would be an option, IMHO. – leyrer Sep 02 '13 at 22:28
  • Current Listbox- choices are only needed in Edit mode... So for me there is no need to update "all" documents... just the one you edit at the moment. But you're right: A Profile- field would be even the better choice... I just wanted to clarify that it IS possible to change the values form "outside" (not directly, but with the mentioned workaround) – Tode Sep 03 '13 at 06:57
  • Thorsten, agreed. But how would you trigger the Java Code for the "current" document, ... That is a road I would not want to go down. Too many "ifs". – leyrer Sep 03 '13 at 07:09