0

I'm using the following code:

<p:inputText label="Bezeichnung"
     required="#{param['form_inhalt:artikeldatatable[0]:entfernen']==null}"
          value="#{artikeldata.bezeichung}"></p:inputText>

I need to access all IDs in this 'artikeldatatable'. How I'm able to do this? It should return false if any button in the table is activated. This works fine with one button [0] but I need to check all buttons in the ID-Array.

#param['form_inhalt:artikeldatatable:0:entfernen']==nullANDparam['form_inhalt:artikeldatatable:1:entfernen']==null}

Is there a way to check the whole array?

Basically I'm searching for a wildcard like * for all IDs from

param['form_inhalt:artikeldatatable:0:entfernen']

to param['form_inhalt:artikeldatatable:99999:entfernen']

Or do I have to write a java script function which iterates to the array and returns true?

If so, how can I access #{param... stuff via Javascript?

Thank you very much!

98percentmonkey
  • 545
  • 7
  • 18
  • What kind of data structure is `form_inhalt:artikeldatatable[0]`? – Smutje Dec 02 '14 at 11:25
  • Primefaces Datatable, List (ArrayList) in the backing bean. "entfernen" is the ID of the commandbutton. – 98percentmonkey Dec 02 '14 at 12:29
  • Is it necessary to access the UI components? Otherwise, you could access the bound view bean object. – Smutje Dec 02 '14 at 12:35
  • http://stackoverflow.com/questions/14335610/jsf-skip-validation-without-immediate-true/14335982#comment42836688_14335982 This was/is my problem, but instead of just one button, I have multiple buttons in every row of the table, so remove elements of the table (where validation should not be executed). – 98percentmonkey Dec 02 '14 at 12:41
  • Why don't you just have all the buttons in the table toggle a single boolean variable? That way you check just one variable in your input text – kolossus Dec 02 '14 at 16:31
  • Sorry for the late reply, nice and simple idea, will test it soon. I posted my not-so-nice-solution as answer. – 98percentmonkey Dec 12 '14 at 14:05

1 Answers1

0
private boolean checkButtonBeschaffung() {
        boolean globalValue = false;
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Map<String, String> parameterMap = (Map<String, String>) facesContext.getExternalContext().getRequestParameterMap();

        for (int i = 0; i < 50; i++) {
            StringBuilder sb = new StringBuilder("form_inhalt:artikeldatatable:");
            sb.append(i);
            sb.append(":entfernen");
            String param = parameterMap.get(sb.toString());
            // Wenn irgendeiner der entfernen Buttons gedrueckt wurde, dann return = false
            if (param == null) {
                globalValue = true;
            } else {
                globalValue = false;
                break;
            }
        }
        return globalValue;
    }

I'm runing through the RequestParameterMap and I will check all buttons (ok till 50) if they have been pressed.

98percentmonkey
  • 545
  • 7
  • 18