rinku_chowdhury
I'm new here

script: retrieve values from CMS_INPUT_CHECKBOX

Jump to solution

I am writing a script (FS v5) where I need to retrieve the value of the selected checkbox and do... but however, the below suggestion (thread#35371) seems do not work in such scenario. Something is wrong with my approach. any clue, please?

Form :

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

    <ENTRIES>

      <ENTRY value="user 1">

        <LANGINFOS>

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

        </LANGINFOS>

      </ENTRY>

     <ENTRY value="user n">

        <LANGINFOS>

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

        </LANGINFOS>

      </ENTRY>

     </ENTRIES>

</CMS_INPUT_CHECKBOX>

script:

import java.util.*;

import de.espirit.firstspirit.forms.FormField;

import de.espirit.firstspirit.forms.FormData;

import de.espirit.firstspirit.access.editor.value.Option;

FormData data= context.showForm();

Set<Option> users = data.get(null,"st_user").get(); // line 20

for(Option opt:users){

JOptionPane.showMessageDialog(frame,"users: "+opt.getValue());

}

error:

147759_pastedImage_6.png

even with this statement : FormField filter = data.get (null, "st_user") throwing the same error.

0 Kudos
1 Solution

Accepted Solutions

Hi Michael,
Thanks for the hint but the problem was with "useLanguage" parameter in the Form section. By removing that parameter, the aforementioned snippet works for me as well.

View solution in original post

0 Kudos
2 Replies
mbergmann
Crownpeak employee

Hi Rinku,

I tested the code in the current FS version and it works (when replacing the variable "frame" with "null"). Your version is very old (5.0) and not officially supported anymore.

The reason for your problem may be that the Beanshell version in your FS does not support typed variable declarations at all (even the current one doesn't have full support for generics), at least the error message suggests this.

But as you dont have to use declarations in Beanshell, maybe you just try

Set users = data.get(null,"st_user").get();

or even

users = data.get(null,"st_user").get();

Michael

0 Kudos

Hi Michael,
Thanks for the hint but the problem was with "useLanguage" parameter in the Form section. By removing that parameter, the aforementioned snippet works for me as well.

0 Kudos