0

I'm getting this javax.faces.model.NoRowAvailableException and i guess it is related to the bean scope or to the metadata id attribute. The exception is thrown when I submit the modifications of a row (p:rowEditor's check button).

jsf page:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:metadata>
        <f:viewParam name="id" value="#{definitionsFacelet.id}"/>
        <f:event type="preRenderView" listener="#{definitionsFacelet.init}" />
    </f:metadata>
    <h:head>
    <title>#{definitionsFacelet.plan.name}</title>
    </h:head>
    <h:body>
        <h1><h:outputText value="#{definitionsFacelet.plan.name}"/></h1>
        <f:view>
            <h:form>
                <h:messages class="errorMessage" id="defsMessages" />
                <p:dataTable value="#{definitionsFacelet.plan.definitions}" var="item" editable="true">
                    <p:ajax event="rowEdit" listener="#{definitionsFacelet.onEditDefinition}" update="@form:defsMessages" />
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Resource"/>
                        </f:facet>
                        <h:outputText value="#{item.resource.name}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Value"/>
                        </f:facet>
                        <p:cellEditor>
                            <f:facet name="output">  
                                <h:outputText value="#{item.value}"/>
                            </f:facet>
                            <f:facet name="input">  
                                <h:inputText value="#{item.value}"/>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Price"/>
                        </f:facet>
                        <p:cellEditor>
                            <f:facet name="output">  
                                <h:outputText value="#{item.price}"/>
                            </f:facet>
                            <f:facet name="input">  
                                <h:inputText value="#{item.price}"/>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>
                    <p:column width="6%">
                        <f:facet name="header">
                            <h:outputText value="Edit"/>
                        </f:facet>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </f:view>
    </h:body>
</html>

and the managed bean:

/**
 *
 * @author oliver
 */
package XXX;

import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import XXX.DefinitionsControlInterface;
import XXX.PlansControlInterface;
import net.elegit.store.model.Plan;
import org.primefaces.event.RowEditEvent;

@ManagedBean
@RequestScoped
public class DefinitionsFacelet implements Serializable {

@EJB
DefinitionsControlInterface definitionsBean;

@EJB
PlansControlInterface planBean;

@ManagedProperty("#{param.id}")
private int id;

private Plan plan;

public void init(){
    System.out.println("ID: "+id);
    plan = planBean.get(id);
}

public String onEditDefinition(RowEditEvent event) {
    return null;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public Plan getPlan() {
    return plan;
}

public void setPlan(Plan plan) {
    this.plan = plan;
}

}

This problem seems like the problem on Jsf DataModel vs Java List problem ( no row available exception ) but only answer there did not helped me.

Best regards, Oliver

Community
  • 1
  • 1
  • when I try to change the scope of the bean from Requesto to ViewScoped the following error is triggered: `Unable to create managed bean definitionsFacelet. The following problems were found: - The scope of the object referenced by expression #{param.id}, request, is shorter than the referring managed beans (definitionsFacelet) scope of view` This behavior seems normal to me since the id parameter only exists when the page is requested but the value is not keep by the container. – Oliver Longhi May 05 '14 at 05:13
  • You can't inject a bean/object into another bean of a narrower scope. `param` is in the request scope, meaning you can inject it only into a `@SessionScoped` bean. That is not to say you should make your bean `@SessionScoped` – kolossus May 05 '14 at 17:46
  • Have you tried with a different scope, rather than "RequestScoped"? Can you try with @SessionScoped to see if the problem persists? – Mateus Viccari Apr 20 '15 at 16:53

0 Answers0