Topic
  • 4 replies
  • Latest Post - ‏2008-06-18T21:10:51Z by SystemAdmin
brittany_lazarski
brittany_lazarski
42 Posts

Pinned topic Multi-value select field not saving properly

‏2008-04-04T16:07:51Z |
I am using a Select builder to provide a multi-value select field, in conjunction with a Domino View & Form builder. The end result I want is for multiple values to be stored in that domin document (the Domino field allows multiple values). I am running into 2 issues:

1. The select field displays great, but when I select more than one option and save, it only saves ONE of the values (not all of the ones I selected).

2. When I put a document into edit mode, the select field does not highlight the value that was saved to the field.

Please help, as this is the first time I am using a multi-value select field in portlet factory!

Brittany
Updated on 2008-06-18T21:10:51Z at 2008-06-18T21:10:51Z by SystemAdmin
  • brittany_lazarski
    brittany_lazarski
    42 Posts

    Re: Multi-value select field not saving properly

    ‏2008-04-04T18:06:48Z  
    I ended up doing this...........

    For the issue with the selected values not appearing highlighted:
    In the Select builder, I set the "Selected values" field to default to what was in the field itself (Category is the name of the field): ${Variables/paDominoview_document/DocumentItems/Category}

    For the issue of all the selected values not being saved, I run this LJO on save:

    public void getProductCategories(WebAppAccess myWebApp){
    {
    // Get an Iterator for the select input
    Iterator i = myWebApp.getRequestInputs().getInputValues("Category");

    // We also set a local variable to an empty string
    String selectedData = "";
    String separator = "";

    // Use a while loop to run through the Iterator to get each select value
    while(i.hasNext())
    {

    // Get the current value from the Iterator
    String value = (String)i.next();

    // append each value to the selectedData String variable
    selectedData = selectedData + separator + value;

    separator = ",";
    }

    //Set Category field to the selectedData string here
    .........

    }
    }
  • SystemAdmin
    SystemAdmin
    334 Posts

    Re: Multi-value select field not saving properly

    ‏2008-06-17T11:50:32Z  
    I ended up doing this...........

    For the issue with the selected values not appearing highlighted:
    In the Select builder, I set the "Selected values" field to default to what was in the field itself (Category is the name of the field): ${Variables/paDominoview_document/DocumentItems/Category}

    For the issue of all the selected values not being saved, I run this LJO on save:

    public void getProductCategories(WebAppAccess myWebApp){
    {
    // Get an Iterator for the select input
    Iterator i = myWebApp.getRequestInputs().getInputValues("Category");

    // We also set a local variable to an empty string
    String selectedData = "";
    String separator = "";

    // Use a while loop to run through the Iterator to get each select value
    while(i.hasNext())
    {

    // Get the current value from the Iterator
    String value = (String)i.next();

    // append each value to the selectedData String variable
    selectedData = selectedData + separator + value;

    separator = ",";
    }

    //Set Category field to the selectedData string here
    .........

    }
    }
    Hi Brittany,

    I am still having a problem with this issue. Would it be possible to send me the model where you have implemented this ?

    Thanks

    Message was edited by: Pauly
    Updated on 2008-06-17T11:50:32Z at 2008-06-17T11:50:32Z by SystemAdmin
  • brittany_lazarski
    brittany_lazarski
    42 Posts

    Re: Multi-value select field not saving properly

    ‏2008-06-17T14:15:51Z  
    Hi Brittany,

    I am still having a problem with this issue. Would it be possible to send me the model where you have implemented this ?

    Thanks

    Message was edited by: Pauly
    I ran into a small issue with that solution, so I went another route after I posted that answer. This solution is very similar, with a couple changes.

    I have 2 Event Handler builders; one for the save event when editing and one for the save event when creating. The Events are System events, and they are called "System:Form:<dominoForm>Create_SaveDataSubmitEvent" and "System:Form:<dominoForm>Edit_SaveDataSubmitEvent". In those handlers, I set the Category field to the result of a Java function.

    Here is the action that sets the field in the Event Handler
    EDIT
    Assignment!DataServices/paDominoview/updateDocument/inputs/DocumentItems/Category=${MethodCall/DomUtils.getProductCategory}
    CREATE
    Assignment!Variables/paDominoview_documentToCreate/DocumentItems/Category=${MethodCall/DomUtils.getProductCategory}

    Here is the getProductCategory function
    /**
    * @return Run from edit and submit "save" event handlers
    * Gets the selected values from the Category field, which is a multi-value select field
    * on the Dom V&F, and returns the string. That string is then
    * returned back to the action list, and it set in the Category field.
    */
    public String getProductCategory(WebAppAccess myWebApp ){
    {
    // Get an Iterator for the select input
    Iterator i = myWebApp.getRequestInputs().getInputValues("Category");

    // We also set a local variable to an empty string
    String finalString="";

    // Use a while loop to run through the Iterator to get each select value
    while(i.hasNext())
    {

    // Get the current value from the Iterator
    String value = (String)i.next();
    if (finalString.equals("")){
    finalString=value;
    }
    else{
    finalString+= ","+value;
    }
    }
    //System.out.println(finalString);
    return finalString;
    }
    }
  • SystemAdmin
    SystemAdmin
    334 Posts

    Re: Multi-value select field not saving properly

    ‏2008-06-18T21:10:51Z  
    I ran into a small issue with that solution, so I went another route after I posted that answer. This solution is very similar, with a couple changes.

    I have 2 Event Handler builders; one for the save event when editing and one for the save event when creating. The Events are System events, and they are called "System:Form:<dominoForm>Create_SaveDataSubmitEvent" and "System:Form:<dominoForm>Edit_SaveDataSubmitEvent". In those handlers, I set the Category field to the result of a Java function.

    Here is the action that sets the field in the Event Handler
    EDIT
    Assignment!DataServices/paDominoview/updateDocument/inputs/DocumentItems/Category=${MethodCall/DomUtils.getProductCategory}
    CREATE
    Assignment!Variables/paDominoview_documentToCreate/DocumentItems/Category=${MethodCall/DomUtils.getProductCategory}

    Here is the getProductCategory function
    /**
    * @return Run from edit and submit "save" event handlers
    * Gets the selected values from the Category field, which is a multi-value select field
    * on the Dom V&F, and returns the string. That string is then
    * returned back to the action list, and it set in the Category field.
    */
    public String getProductCategory(WebAppAccess myWebApp ){
    {
    // Get an Iterator for the select input
    Iterator i = myWebApp.getRequestInputs().getInputValues("Category");

    // We also set a local variable to an empty string
    String finalString="";

    // Use a while loop to run through the Iterator to get each select value
    while(i.hasNext())
    {

    // Get the current value from the Iterator
    String value = (String)i.next();
    if (finalString.equals("")){
    finalString=value;
    }
    else{
    finalString+= ","+value;
    }
    }
    //System.out.println(finalString);
    return finalString;
    }
    }
    wooo hooo ... thanks Brittany - works like a dream.