vasanth
I'm new here

Is it possible to add the entries to CMS_INPUT_CHECKBOX dynamically ??

I have requirement that i should change the entries of CMS_INPUT_CHECKBOX based up on the CMS_INPUT_COMBOBOX.  Is it possible to change entries of the CMS_INPUT_CHECKBOX based up on the selection of CMS_INPUT_COMBOBOX ??

  <CMS_INPUT_COMBOBOX name="st_group" hFill="yes" useLanguages="no">

    <CMS_INCLUDE_OPTIONS type="public">

      <LABELS>

        <LABEL lang="*">#item.name</LABEL>

      </LABELS>

      <NAME>GroupComponent</NAME>

    </CMS_INCLUDE_OPTIONS>

    <LANGINFOS>

      <LANGINFO lang="*" label="Groups"/>

    </LANGINFOS>

  </CMS_INPUT_COMBOBOX>

  <FS_BUTTON name="st_button" onClick="script:get_all_user" useLanguages="no">

    <LANGINFOS>

      <LANGINFO lang="*" label="Fetch Users"/>

    </LANGINFOS>

    <PARAMS>

      <PARAM name="group">#field.st_group</PARAM>

      <PARAM name="user">#field.st_user</PARAM>

    </PARAMS>

  </FS_BUTTON>

  <CMS_INPUT_CHECKBOX name="st_user" hFill="yes" hidden="no" useLanguages="no">

    <ENTRIES>

      <ENTRY value="demo">

        <LANGINFOS>

          <LANGINFO lang="*" label="demo"/>

        

        </LANGINFOS>

      </ENTRY>

      <ENTRY value="demo1">

        <LANGINFOS>

          <LANGINFO lang="*" label="2nd label"/>         

        </LANGINFOS>

      </ENTRY>

    </ENTRIES>

    <LANGINFOS>

      <LANGINFO lang="*" label="Users"/>

    </LANGINFOS>

  </CMS_INPUT_CHECKBOX>

0 Kudos
11 Replies
felix_reinhold
Returning Responder

Hello,

if it's okay for you to use an additional button as seen in your XML Snippet, then I'd replace the st_user dropdown by a CMS_INPUT_TEXT component and set editable to no. Then with the button you create a new form (see ShowFormDialogOperation) that contains a ComboBox that you create on the fly. It shows the users of the previously selected group. If there are only a few users per group then you can create the Entries of the ComboBox by writing the GOM-XML manually. If not, then I'd create another HotSpot that can receive the Group as PARAM.

When the editor selects a user from the ComboBox and closes the dialog you can write the selected user to the CMS_INPUT_TEXT component. In addition you could add a hidden TEXT-Field that holds the loginname of the user if you need more information from the user-object then the display-name.

Best regards

Felix

0 Kudos

Hey Felix,

Thank you for idea. So i plan to use the HotSpot as below But i have doubt how to get the param in MwfUserComponent ?? Do you have any idea ??

/**

*

*/

package com.bosch.firstspirit.mwf.component;

import java.util.List;

import de.espirit.firstspirit.access.User;

import de.espirit.firstspirit.access.store.templatestore.gom.GomIncludeValueProvider;

import de.espirit.firstspirit.agency.SpecialistsBroker;

public class MwfUserComponent implements GomIncludeValueProvider<User> {

@Override

public Class<User> getType() {

// TODO Auto-generated method stub

return User.class;

}

@Override

public List<User> getValues(SpecialistsBroker paramSpecialistsBroker) {

// TODO Auto-generated method stub

return null;

}

@Override

public String getKey(User user) {

// TODO Auto-generated method stub

return user.getLoginName();

}

}

<CMS_INPUT_COMBOBOX name="st_group" hFill="yes" useLanguages="no">

    <CMS_INCLUDE_OPTIONS type="public">

      <LABELS>

        <LABEL lang="*">#item.name</LABEL>

      </LABELS>

      <NAME>MwfGroupComponent</NAME>

    </CMS_INCLUDE_OPTIONS>

    <LANGINFOS>

      <LANGINFO lang="*" label="Groups"/>

    </LANGINFOS>

  </CMS_INPUT_COMBOBOX>

    <CMS_INPUT_CHECKBOX name="st_user" hFill="yes" hidden="no" useLanguages="no">

    <CMS_INCLUDE_OPTIONS type=public>

    <NAME>MwfUserComponent</NAME>

    <PARAMS>

    <PARAM name="group">#field.st_group</PARAM>

    </PARAMS>

    <LANGINFOS>

      <LANGINFO lang="*" label="Users"/>

    </LANGINFOS>

  </CMS_INPUT_CHECKBOX>

0 Kudos

Your Hotstpot needs to implement the Parameterizable interface. But it can only work with String parameters. That's why you have to use the button as mentioned above. Pass the value of st_group to the script used in the button. In the script you build another form on the fly (ShowFormDialogOperation) and set the param of the Combobox in the GOM XML representation. The only option without a button would be sth. pretty experimental - e. g. you could create a ValueService that writes the value of st_group somewhere and you read that value in the hotspot. But I'm not sure if the values of the Combobox would be updated without a refresh of the form.

0 Kudos

felix.reinhold​ I am plan to use the Option 1 (on the fly form creation using ShowFormDialogOperation) But i have a doubt is that the value selected won't be persisted right (in the sense i need to choose the user every time) ?? and also how to access the user selection in the HTML channel of group form ??

Is it possible to create  create the tabs dynamically (only once)

224670_pastedImage_0.png

0 Kudos
felix_reinhold
Returning Responder

I think you got me wrong.

Your form  will contain the Group-Combobox, a Button, a hidden textfield (for the user loginname) and a visible textfield with editable=no for th user display-name (Another option would be a combobox that uses the new UserHotspot with editabe=no instead of the two textfields).

The button receives three parameters:

  • the group-combobox
  • both textfields

The script that is assigned to the button creates a new form with the ShowFormDialogOperation.

<CMS_INPUT_COMBOBOX name="st_user" useLanguages="no" >

    <CMS_INCLUDE_OPTIONS type="public">

      <LABELS>

        <LABEL lang="*">#item.name</LABEL>

      </LABELS>

      <NAME>MwfUserComponent</NAME>

      <PARAMS>

        <PARAM name="group">Value from group-combobox</PARAM>

      </PARAMS>

    </CMS_INCLUDE_OPTIONS>

    <LANGINFOS>

      <LANGINFO lang="*" label="User"/>

    </LANGINFOS>

  </CMS_INPUT_COMBOBOX>

The script sets the value that the user selects to the provided textfields. Those textfields can be used as every other field in your template.

0 Kudos

felix.reinhold​ thank you for your suggestion. It seems to be a work around for me and what about creating a new FS component CMS_INPUT_TREE for this requirement and is that feasible ??

0 Kudos
felix_reinhold
Returning Responder

I think that this problem won't be solved by using CMS_INPUT_TREE because you also can't add the entries dynamically. based on another Combobox.

0 Kudos

felix.reinhold​ No, the CMS_INPUT_TREE will be static not no more combobox in the form. Because the tree structure will have everything

225129_pastedImage_0.png

0 Kudos

It should be possible like this, but keep in mind, that every user who is member of different groups appears multiple times in the tree.

0 Kudos