wiegele
I'm new here

Werte aus CMS_INPUT_CHECKBOX lesen

Jump to solution

Hallo zusammen,

ich möchte in einem Beanshell Script die Werte aus einer CMS_INPUT_CHECKBOX Eingabe auslesen.

Das Script soll ein Form öffnen, der Benutzer selektiert die Filter und mit den selektierten Werten soll dann eine Suche erfolgen.

Leider komme ich nicht an die einzelnen selektierten Werte, aus der CMS_INPUT_CHECKBOX.

Natürlich benötige ich nicht die FS_IDS aus der DB sondern die sprachabhängigen Werte.

Ich habe alle Threads mit CMS_INPUT_CHECKBOX hier im Forum durch.

Das war noch am vielversprechendsten, leider bring mich das auch nicht richtig weiter.

https://community.e-spirit.com/message/21477#21477

<CMS_MODULE>

<CMS_GROUP name="MeinForm">

<CMS_INPUT_CHECKBOX name="cs_filter_to_replace" gridWidth="4" hFill="yes" useLanguages="no">

      <CMS_INCLUDE_OPTIONS type="database">

        <LABELS>

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

          <LABEL lang="EN">#item.displayName_EN</LABEL>

        </LABELS>

        <TABLE>FS1_Tables.filter</TABLE>

      </CMS_INCLUDE_OPTIONS>

      <LANGINFOS>

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

      </LANGINFOS>

    </CMS_INPUT_CHECKBOX>

  </CMS_GROUP>

</CMS_MODULE>   

import de.espirit.firstspirit.forms.FormField;

FormData form1=context.showForm(false);

if (form1 != null) {

GomFormElement pGomFormField = form1.getForm().findEditor( "cs_filter_to_replace" );

pOptionFactory = pGomFormField.getOptionFactory();

}

So richtig komme ich aber nicht weiter.Hat jemand ein Beispiel?

Danke fürs lesen.

0 Kudos
1 Solution

Accepted Solutions
mbergmann
Crownpeak employee

Hallo Dirk,

mit dem GomFormElement biegst du in die falsche Richtung ab, das ist die "Definitionsseite" des Formulars.

form1.get(null,"cs_filter_to_replace").get()

liefert hier ein Set<Option> - und zwar bestehend nur aus den angehakten.

Über das Set kannst Du iterieren, für jeweils eine Option kommst Du dann per

option.getValue()

an eine Entity.

Viele Grüße

Michael

View solution in original post

0 Kudos
5 Replies
mbergmann
Crownpeak employee

Hallo Dirk,

mit dem GomFormElement biegst du in die falsche Richtung ab, das ist die "Definitionsseite" des Formulars.

form1.get(null,"cs_filter_to_replace").get()

liefert hier ein Set<Option> - und zwar bestehend nur aus den angehakten.

Über das Set kannst Du iterieren, für jeweils eine Option kommst Du dann per

option.getValue()

an eine Entity.

Viele Grüße

Michael

0 Kudos
marza
I'm new here

Hallo Dirk,

benötigst Du noch weitere Hilfe oder haben Dir die Antworten von Michael bereits geholfen?

In diesem Fall wäre es super, wenn Du die "richtige Antwort" entsprechend markierst, damit auch andere Community-Teilnehmer diese auf den ersten Blick finden. Solltest Du zwischenzeitlich eine eigene Lösung gefunden haben, wäre es nett, wenn Du diese hier bereitstellst.

Viele Grüße

Marian

0 Kudos

Hallo zusammen,

nur der Vollständigkeit halber.

  StoreAgent storeAgent = context.requireSpecialist(StoreAgent.TYPE);

  ContentStoreRoot cs = storeAgent.getStore(Store.Type.CONTENTSTORE);

  TemplateStoreRoot ts = storeAgent.getStore(Store.Type.TEMPLATESTORE);

  Content2 csPressreleases = cs.getStoreElement("DeineDatenQuelle", Content2.UID_TYPE);

  FormData form1=context.showForm(false);

  Dataset dataSet = null;

  FormData data = null;

  FormField formFieldEntity =null;

  if(csPressreleases!=null && form1!=null){

  FormField filter = form1.get(null, "DeinCMS_InputCheckBox_EingabeFeld");

  Set<Option> valuesFilter = filter.get();

  for (Option opt : valuesFilter)

  {

  dataSet = csPressreleases.getDataset(opt.getValue());

  data = dataSet.getFormData();

  formFieldEntity = data.get(null, "cs_refName");

  //Ausgabe auf die Java Konsole

  print(formFieldEntity.get());

  }

  }

0 Kudos

I am writing a script (FS v5) where I need to retrieve the value of the selected checkbox and do... but however, the aforementioned suggestions seem 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:

FormData data= context.showForm();

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

for(Option opt:users){

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

}

error:

147758_pastedImage_6.png

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

0 Kudos

Hello Rinku,

as this question has been marked as "answered" and is more than three years old, you should normally open a new thread and link to this one.

But maybe it is just a small typo - you use a small "O" in the line

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

instead of a capital one 😉

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

Oh, and do you have an import for "Option"?

If that does not solve your problem, please open a new thread as "anwered" threads don't get that much attention.

Michael

0 Kudos