0

I have following block of code:

<ui:repeat
    value="#{view.listOfItems}"
    var="var" id="list">                    
        <td>
            <h:selectOneMenu id="status" styleClass="form-control" value="${var.status().text()}">
                <f:selectItems id="statusDdl" value="#{view.statusToApply.getLabels()}" />
            </h:selectOneMenu>
        </td>
</ui:repeat>

This block of code is inside a uiRepeat tag, so for every var in my list I repeat this block of code. I'd need a way to have a method launch in my View on select of a selectItem, with as parameter the actual label of that selectItem and the var to be changed, so that, based on that label, I can myself put a new status in the var. After that I'll probably need to rerender that specific selectOneMenu component to show the new status.

How can this be achieved? Thanks in advance.

SimonartM
  • 668
  • 2
  • 11
  • 26
  • Why do you describe the existing (relevant as it seems) code and do not post it in the question **as code**? (In [mcve] format please) – Kukeltje Feb 07 '20 at 13:42
  • additional comments: an `h:uiRepeat` does not exist. 2: There is no f:ajax in your code anywhere, 3: `value="${var.status().text()}"` is uncommon (iirc, wrong even) – Kukeltje Feb 07 '20 at 14:33
  • Thanks for your replies, indeed I made a mistake with the h:uiRepeat. I'll add the code of the uiRepeat in a second. The ajax isn't present 'cause that's my question. Is it possible to pass on a list of strings as selectItems and onSelect of one of these items, have a method launch in my view with the onSelected string as param and based on that param set a new status object in my var, and once a new status object is set in the var, have the text of that status object show in the value of the h:selectOneMenu tag, which is exactly the same string as the one selected in the selectItem list – SimonartM Feb 07 '20 at 14:43
  • Why don't you TRY to add ajax and see what happens? And if you get errors, search for those...? – Kukeltje Feb 07 '20 at 14:59
  • 1
    Step 1: https://stackoverflow.com/questions/10396244/how-to-pass-parameter-to-fajax-in-hinputtext-fparam-does-not-work based on a query in a search engine without 'ui:repeat' in it. With this in it, check the results: https://www.google.com/search?client=firefox-b-d&q=pass+parameter+in+listener+jsf+f%3Aajax+in+repeat+site%3Astackoverflow.com – Kukeltje Feb 07 '20 at 15:12
  • Thank you for your help. I know I should try on my own, but thing is, I'm refactoring code, I can't at the moment run the code I have, the program just doesn't get there yet. And It still requires lot of work, but I just mainly needed to know 'IF' it was possible, because this influences a lot on how I will write the future code. But I'll continue reading on the ajax subject because I'm not familiar enough with it. Thanks for the help once again. – SimonartM Feb 07 '20 at 15:27
  • Yes it is possible – Kukeltje Feb 07 '20 at 20:55

0 Answers0