0

I'm creating a small application using JSF,facing the exception, below is the code for the form.

  <h:form>

 <h:selectManyCheckbox value="#{transferMB.selectedItems}">
    <f:selectItem itemValue="1" itemLabel="Transfer Status" />
      <p:ajax update=":transForm" />
 </h:selectManyCheckbox>

</h:form>

exception " javax.faces.view.facelets.TagAttributeException:"

Josef E.
  • 2,179
  • 4
  • 15
  • 30
user3684675
  • 381
  • 4
  • 8
  • 32

2 Answers2

1

You should be calling Boolean-like values into your rendered attributes.

Example:

<p:panelGroup id="group" rendered="{#bean.isOneSelected}">
...
</p:panelGroup>

<p:panelGroup id="group" rendered="{#bean.isTwoSelected}">
...
</p:panelGroup>

And for getting values from selectManyMenu. Please check here.


Also the rendered tag is a Boolean like condition to tell whether a tag should be displayed. You shouldn't need to pass a parameter into that. You should be getting that information from you transferMB

Josef E.
  • 2,179
  • 4
  • 15
  • 30
  • Please see the above post, added code followed by the exception iam facing @Josef E. – user3684675 Jun 17 '14 at 19:02
  • @user3684675 Is there any other way you can get that `needed` value? Maybe have it passed to the been from a hidden field or is that user entered? Because 'rendered' cannot have a parameter passed into it. – Josef E. Jun 17 '14 at 19:25
  • oh..but without passing i cannot check the condition,which checkbox is checked. – user3684675 Jun 17 '14 at 19:38
  • You have an `ajax` tag in your selectmenu. Use that to update, corresponding values in your bean. I'll edit my answer @user3684675 – Josef E. Jun 17 '14 at 19:40
  • but when i researched i came to know that 'rendered' can call other method to check the condition. I think it might be some jar issue but not sure..@Josef E. – user3684675 Jun 17 '14 at 19:43
  • It is not a jar issue. You are calling the method, but you cannot pass parameters into it. Rendered is a boolean-like attribute. @user3684675 – Josef E. Jun 17 '14 at 19:47
  • oh ok. then i should see some other way to get the selected checkbox value to know which checkbox have been selected. But one question, if you see controlSelectedValues(..) method it is returning a boolean value. – user3684675 Jun 17 '14 at 19:49
  • +1 for your suggestions and time, i got what u told but how can i pass the selected checkbox value to bean and from their how to pass to controlSelectedValues(..). – user3684675 Jun 17 '14 at 19:55
  • You could create a listener with your `ajax` call **Example** http://stackoverflow.com/questions/10287115/primefaces-ajax-listener-not-executed-when-process-attribute-is-specified-for-a – Josef E. Jun 17 '14 at 19:57
  • Also try this link http://stackoverflow.com/questions/14824178/getting-selected-value-of-a-selectonemenu @user3684675 In addition with last comment – Josef E. Jun 17 '14 at 20:00
1

This is a follow-up for issue while loading data

As mentioned there, you need to use EL 2.2 for passing parameter inside EL-Expressions. Seems you don't use that.

So we need another way to get this solved:

<h:form id="transForm">
    <p:panelGrid columns="1" rendered="#{transferMB.transFormEnabled}">
        <h:outputText value="transForm"/>
    </p:panelGrid>
</h:form>
<h:form id="spreadForm">
    <p:panelGrid columns="1" rendered="#{transferMB.spreadFormEnabled}">
        <h:outputText value="spreadForm"/>
    </p:panelGrid>
</h:form>

and in your corresponding bean:

public boolean isTransFormEnabled() {
    if (selectedItems.contains("1")) {
        return true;
    } else {
        return false;
    }
}
public boolean isSpreadFormEnabled() {
    if (selectedItems.contains("2")) {
        return true;
    } else {
        return false;
    }
}
Community
  • 1
  • 1
Ishkafel
  • 333
  • 1
  • 10