0

0 and i need to render some buttons based on condition, i'm getting the condition true but each time i visit the page the button its displaying with additionl buttons,here's my code

<ui:repeat var="r" value="#{sessionScope['restrictpageload']}" varStatus="status">    
    <ui:repeat var="permission" value="#{restrictPageLoad.isUserHasFeaturePermission(4,'abc')}" varStatus="status2">
        <ui:fragment rendered="#{permission.featureCreate eq 'y'}" >
            <h:commandButton value="Button1" action="#{bean.method()}"/>
        </ui:fragment>
    </ui:repeat>        
</ui:repeat>

here my first <ui:repeat> gets the values from session and i'll pass as parameter to second and this will return me arraylist and i'm going to render the button based on condition.

I'm getting the values inside but each time i visit page two more button addsup.Please help.

LaurentG
  • 11,128
  • 9
  • 51
  • 66
user2644886
  • 31
  • 1
  • 1
  • 5
  • Where and how get's `restrictpageload` filled into the sessionScope? – L-Ray Jan 16 '14 at 08:11
  • @L-Ray i'm getting the values from backing bean and its a arraylist and i'm keeping it in session based on logged user. – user2644886 Jan 16 '14 at 08:26
  • Can you maybe post the managed bean? If the bean is not in session scope and you do that fill on every construct/init of the bean, that might a reason ... – L-Ray Jan 16 '14 at 08:45

1 Answers1

0

too long for a comment...

3 points:

  1. outer loop declares r and status which are not used in inner loop, so "here my first <ui:repeat> gets the values from session and i'll pass as parameter to second" is false

  2. value="#{sessionScope['restrictpageload']}" is equivalent to value="#{restrictpageload}"

  3. value="#{sessionScope['restrictpageload']}" maybe there's a typo. you mean value="#{sessionScope['restrictPageload']}" (uppercase P)

maybe you want to do something like this:

<ui:repeat var="restriction" value="#{bean.pageRestrictions}">
    <ui:repeat var="permission" value="#{bean.userPermissions}">    
        <ui:fragment rendered="#{restriction == permission}">
            <h:commandButton value="Button1" action="#{bean.method}"/>
        </ui:fragment>
    </ui:repeat>
</ui:repeat>

or better

<ui:repeat var="restriction" value="#{bean.pageRestrictions}">    
    <ui:fragment rendered="#{bean.userHasFeaturePermission(restriction)}">
        <h:commandButton value="Button1" action="#{bean.method}"/>
    </ui:fragment>
</ui:repeat>

however if your buttons are duplicating, you are adding something to your loops, maybe in isUserHasFeaturePermission?


UPDATE (comment reply)

read carefully the accepted answer of your linked question:

Your question is meaningless. There is no "passing parameters by " and there is no "passing parameters using ". Your words might make sense in some specific context - but the context is missing.

not related but worth mention, NEVER use c:forEach in JSF pages, unless you know exactly how JSF lifecycle works.

passing parameters in expressions depends on EL (ExpressionLanguage) library version.

you can pass parameters only if you have EL 2.2+. this library is shipped (normally) with the servlet container.

read this answer and linked for a complete explanation.

what's your servlet container? tomcat 6.0, glassfish 3.1?

however, does it throws an Exception?

Community
  • 1
  • 1
Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73
  • thanks for your reply, i eliminated the outer and now i wanted to call method with parameter. but i saw here (http://stackoverflow.com/questions/15186966/passing-parameters-using-uirepeat) its not possible is there any way i can get the arraylist and iterate. – user2644886 Jan 17 '14 at 04:22