0

I have following nested ui:repeat's. Previously the outer loop was using a c:forEach which worked as expected.

Now i want to use it with omnifaces of:createIntegerArray(1, 7) or using it with omnifaces <o:importConstants> function which is not working.

public static final int[] INTEGER_ARRAY = new int[]{1, 2, 3, 4, 5, 6, 7};
public List<String> getValues(int i);

<ui:repeat var="i" value="#{Bean.INTEGER_ARRAY}">
    #{i}
    <ui:repeat var="value" value="#{bean.getValues(i)}">
        #{value}
    </ui:repeat>
</ui:repeat>

The parameter i is always 0 or null in the bean method but is printed out correctly in the jsf view.

djmj
  • 5,579
  • 5
  • 54
  • 92
  • *the bean method was getting called too often* that's normal behavior, read [Why JSF calls getters multiple times](http://stackoverflow.com/q/2090033/1065197) and the links inside. – Luiggi Mendoza Feb 12 '13 at 16:41
  • What Mojarra version? Can't reproduce in 2.1.17. And indeed, a getter method call is extremely cheap. So if you just return the property, there's nothing to worry about. – BalusC Feb 12 '13 at 16:44
  • It is just a parametrized getter. @LuiggiMendoza the taghandlers as `c:forEach` can also be responsible for view bean recreation which I tried to avoid. @BalusC I updated today to 2.1.18 for testing purpose but still the same. – djmj Feb 12 '13 at 16:49
  • @djmj and will be the same because behind the scenes the getter will get called multiple times, knowing this you should **never** write business logic in your getter/setter methods for JSF and CDI managed beans. – Luiggi Mendoza Feb 12 '13 at 16:51
  • There is no business logic. Just wanted to remove taghandlers as much as possible. – djmj Feb 12 '13 at 16:53
  • Wait, do you get any exception? I got an `ELException` in Tomcat when I used `int[]`, but not when I used `Integer[]` (I used `#{of:createIntegerArray(1, 7)}` to stub a quick local test). – BalusC Feb 12 '13 at 16:58
  • No, I just get my own exception which checks if value is greater then 0. Originally i used `#{of:createIntegerArray(1, 7)}` too. – djmj Feb 12 '13 at 16:59
  • Hmm OK, sorry, can't reproduce it. The SSCCE created on a blank playground environment based on the information provided so far works just fine for me. – BalusC Feb 12 '13 at 17:00
  • Thanks for your time anyway, always glad about your help. With `c:forEach` it works so I have no idea. – djmj Feb 12 '13 at 17:04
  • Where is `#{Bean}` coming from? ``? (I wonder if that field shouldn't be `final`...) Is it definied in the same template client? – BalusC Feb 12 '13 at 17:10
  • I was first testing with `#{of:createIntegerArray(1, 7)}` then added the array as a final bean array using it with ``. Was not sure if this information was relevant, edited question. What do you mean by template client? – djmj Feb 12 '13 at 21:14
  • I removed app, cache and all generated files from server and redeployed and now it works again. Oh man, programming sucks :D Sorry to waste your times. – djmj Feb 12 '13 at 21:31
  • @djmj I have the same problem with browsers especially IEx, I don't know if this work for you but I have no problems when I test the results in Chrome. – Luiggi Mendoza Feb 12 '13 at 22:48
  • Hmm interesting, i used firefox for testing. – djmj Feb 12 '13 at 23:16

0 Answers0