1

I have the following JSF page.

enter image description here

The "Manage Attendee" link is defined by the following XHTML:

<h:form>
    <h:commandLink value="Manage Attendees" action="/Management/Event/manageAttendees?faces-redirect=true">
    <f:setPropertyActionListener target="#{managerManager.currentEvent}" value="#{event}" />
    </h:commandLink>
    &nbsp;
    (...)
</h:form>

currentEvent is a field in the "ManagerManager" ManagedBean which is set upon the redirect and refers to the event in the description field. It has a list which we want to iterate through. However, the second page:

enter image description here

Does not render the attributes. Like the currentEvent list was empty, which the debug report says it's not. The following is the code for the second page which should get the title:

<h2>Attendees in this Event</h2>
    <h:dataTable
        var="attendees"
        summary="List of attendees in this event."
        value="#{managerManager.currentEvent.attendees}"
        rules="all"
        cellpadding="5">

        <h:column>
            <f:facet name="header">
                <h:outputText value="Name" />
            </f:facet>
            <h:outputText value="#{attendees.attendee.name}" />
        </h:column>
    </h:dataTable>

The ManagedBean is session scoped as well. It looks like the second page doesn't have access to currentEvent... why?

Deegriz
  • 1,935
  • 1
  • 18
  • 31
  • The dataTable renders empty. It should iterate through all the attendees and display their name – Deegriz Nov 14 '15 at 16:41
  • What exactly is the problem now? "Does not display variable" is as if an enduser would observe the problem. Try observing and describing the problem as a developer, not as an enduser. Is the `f:setPropertyActionListener` working? Is the setter method invoked? Is the passed-in argument correct? Is the very same bean instance accessed in next page or is it a new instance? Etc. Edit the question and please elaborate the problem in developer's perspective. – BalusC Nov 14 '15 at 16:42
  • Yes, all of that is. Maybe I wasn't explicit enough, my bad. I do think I have solved the issue. Removing ?faces-redirect=true from the following line: worked. But it's supposed to be there, right? – Deegriz Nov 14 '15 at 16:44
  • Then the bean is apparently actually not session scoped. – BalusC Nov 14 '15 at 16:45
  • I have the annotation however: @ManagedBean(name = "managerManager") @SessionScoped public class ManagerManager implements Serializable { – Deegriz Nov 14 '15 at 16:46
  • 1
    Correction: "Then the bean is apparently actually not in JSF session scope". – BalusC Nov 14 '15 at 16:48
  • That got me looking through the annotation being imported, I think netbeans might have duped me and imported the wrong one in this specific bean: import javax.enterprise.context.SessionScoped; – Deegriz Nov 14 '15 at 16:52
  • 1
    That's wrong import if you use `@ManagedBean`. – Geinmachi Nov 14 '15 at 16:56
  • Yeah, this wasn't my brightest day... The burnout was getting to me – Deegriz Nov 14 '15 at 16:59

1 Answers1

1

Turns out it as an import statement error.
The @SessionScoped annotation being used in the Managed Bean was from
import javax.enterprise.context.SessionScoped;
rather than
import javax.faces.bean.SessionScoped;
as it obviously should be. Which explains why only this specific page had this issue in my project.

Deegriz
  • 1,935
  • 1
  • 18
  • 31