springjsfprimefacescouchdbektorp

Ektorp ArrayList get all in JSF in the PrimeFaces List component


How can i get my List of existing Tourneys via Ektorp API from CouchDB? My code looks like this:

thanks a lot.

I call the methode getAll() in my TourneyService Class and getAll() is a list of Tourneys

//TourneyService

@Service
public class TourneyService implements Serializable{

private static final long serialVersionUID = 699617628013084160L;

@Autowired
private TourneyRepository tourneyRepository;

public List<Tourney> getAllTourneys(){
    return tourneyRepository.getAll();
}
}

//TourneyRepository

@Component
public class TourneyRepository extends CouchDbRepositorySupport<Tourney> {

@Autowired
public TourneyRepository(@Qualifier("cegocouchdb") CouchDbConnector db) {
    super(Tourney.class, db);
    initStandardDesignDocument();
}

@GenerateView @Override
public List<Tourney> getAll() {
    ViewQuery q = createQuery("all")
                    .descending(true)
                    .includeDocs(true);
    return db.queryView(q, Tourney.class);
}

   }

//TourneyListBean

    @ManagedBean(name = "TourneyListMmgtBean")
    @RequestScoped
    public class TourneyListBean implements Serializable {

private static final long serialVersionUID = 6130842812974474768L;

@ManagedProperty(value = "#{tourneyService}")
private TourneyService tourneyService;

private List<Tourney> tourneys; 

public void onEdit(RowEditEvent event) {
    FacesMessage msg = new FacesMessage("Tourney changed", "");

    FacesContext.getCurrentInstance().addMessage(null, msg);
}

public void onCancel(RowEditEvent event) {
    FacesMessage msg = new FacesMessage("Aktion abgebrochen", "");

    FacesContext.getCurrentInstance().addMessage(null, msg);
}


public TourneyService getTourneyService() {
    return tourneyService;
}

public void setTourneyService(TourneyService tourneyService) {
    this.tourneyService = tourneyService;
}

public List<Tourney> getTourneys() {
    tourneys = tourneyService.getAllTourneys();
    if (tourneys == null) {
        tourneys = new ArrayList<Tourney>();
    }
    return tourneys;
}

public void setTourneys(List<Tourney> torneys) {
    this.tourneys = torneys;
}
   }

JSF

<ui:define name="content">



    <h:form id="form">

        <p:growl id="messages" showDetail="true" />

        <p:dataTable var="tourney" value="#{TourneyListMmgtBean.tourneys}"
            id="tourneyList" editable="true">

            <f:facet name="header">  
        In-Cell Editing  
    </f:facet>

            <p:ajax event="rowEdit" listener="#{TourneyListMmgtBean.onEdit}"
                update=":form:messages" />
            <p:ajax event="rowEditCancel"
                listener="#{TourneyListMmgtBean.onCancel}" update=":form:messages" />

            <p:column headerText="Turniername" style="width:30%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.name}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.name}" style="width:100%"
                            label="Turniername" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column headerText="Straße" style="width:20%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.street}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.street}" style="width:100%"
                            label="Straße" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column headerText="Turnierstadt" style="width:24%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.city}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.city}" style="width:100%"
                            label="Turnierstadt" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column headerText="Beginnzeit" style="width:24%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.beginTime}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.beginTime}" style="width:100%"
                            label="Beginnzeit" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column headerText="Endzeit" style="width:24%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.endTime}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.endTime}" style="width:100%"
                            label="Endzeit" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column headerText="Turnierpunkte" style="width:24%">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{tourney.points}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText value="#{tourney.points}" style="width:100%"
                            label="Turnierpunkte" />
                    </f:facet>
                </p:cellEditor>
            </p:column>

            <p:column style="width:6%">
                <p:rowEditor />
            </p:column>

        </p:dataTable>

    </h:form>

</ui:define>

Error:

org.ektorp.support.ViewGenerationException: Cannot generate 'all' view for null.

Solution

  • @GenerateView has the following constraints:

    Verify that you have an @TypeDiscriminator in your Tourney class