0

I would like to create a p:datatable in another p:datatable with primefaces. As long is i only display values (using outputText), everything is ok. But if i want to change the values using inputText, i got the following exception once i send my form.

Caused by: javax.el.PropertyNotFoundException: Target Unreachable, 'lineItem' returned null at org.apache.el.parser.AstValue.getTarget(AstValue.java:127) [jbossweb-7.0.17.Final.jar:] at org.apache.el.parser.AstValue.getType(AstValue.java:82) [jbossweb-7.0.17.Final.jar:] at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:176) [jbossweb-7.0.17.Final.jar:] at org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93) [weld-core-1.1.9.Final.jar:2012-08-06 19:12] at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98) [jsf-impl-2.2.0-m10.jar:2.2.0-m10-SNAPSHOT] ... 46 more

Here is my bean:

@ManagedBean
@ViewScoped
public class OmsOrderActionBean implements Serializable {

private Order order;

public String init(){
    number = facesContext.getExternalContext().getRequestParameterMap().get("number");
    dtype = CharUtils.toChar(facesContext.getExternalContext().getRequestParameterMap().get("dtype"), ' ');

    if (!StringUtils.isEmpty(number)) {
        Order order = orderDao.findOrderByNo(number);

        if (order == null) {
            JSFUtil.flashScope().put("oid", number);
            return UiConstants.NAV_ERROR_NOT_FOUND;
        }

        setOrder(order);
public Order getOrder() {
    return order;
}
}

Here is my order:

@Entity    
@Table(name = "orders")
@Inheritance(strategy = InheritanceType.JOINED)
public class Order extends DefaultEntityTemplate implements Serializable, Cloneable {

// bi-directional many-to-one association to OrderGroup
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@Fetch(FetchMode.SUBSELECT)
private List<OrderGroup> orderGroups;


public List<OrderGroup> getOrderGroups() {
    if (orderGroups == null) {
        orderGroups = new ArrayList<>();
    }
    return orderGroups;
}

public void setOrderGroups(List<OrderGroup> orderGroups) {
    if (!CollectionUtils.isEmpty(orderGroups)) {
        for (OrderGroup orderGroup : orderGroups) {
            orderGroup.setOrder(this);
        }
    }

    getOrderGroups().clear();
    getOrderGroups().addAll(orderGroups);
}
}

And here is my xhtml page:

<f:metadata>
    <f:viewAction action="#{omsOrderActionBean.init()}" />
</f:metadata>

<p:outputPanel id="outpOrderGroups">
<p:dataTable id="orderGroupTbl" var="group" value="# omsOrderActionBean.order.orderGroups}" emptyMessage="" >
<p:column>
<p:dataTable var="oglineItem" value="#{group.orderGroupLineItems}" emptyMessage="">
 <p:column>
  <h:inputText id="quantityInput" value="#{oglineItem.lineItem.quantity}"/>
 </p:column>
</p:dataTable>
</p:outputPanel>

Has anybody already tried somtheing like that? OrderGroupLineItem and LineItem are other entities. I could also add them if needed.

jobe
  • 335
  • 2
  • 12
  • 23
  • This suggests that the bean is request scoped and that the data model is not prepared in its (post)constructor. You'd need to show some code in SSCCE flavor in order to naildown it. – BalusC Sep 20 '13 at 14:35
  • What does it mean exactly? I don't realy see what you meen with that. Do you have an example or good readings? i looked at http://sscce.org/ but it didn't really helped. Thx for your help! – jobe Sep 20 '13 at 15:31
  • Our JSF wiki page has some guidelines: http://stackoverflow.com/tags/jsf/info. After all, it's just the smallest possible but complete example which reproduces the very problem for us (and yourself!) when copypasted unmodified (at least, without the "obvious" such as package and import declarations and getters/setters) into a blank playground environment. – BalusC Sep 20 '13 at 15:32
  • This still suggests that the bean is in request scope. What package is `@ViewScoped` from? JSF 2.2 has two in different packages. Also, did you put a breakpoint in the constructor/postconstruct/init to check if it isn't unintentionally invoked on postback? – BalusC Sep 22 '13 at 19:29
  • I don't think my bean is in resquest scope. Everywhere else or if i don't use nested datatables, everything works fine. Also the data in the outer datatable are saved correctly. Only the data in the inner datatable generate an exception. – jobe Sep 23 '13 at 05:39
  • it is javax.faces.bean.ViewScoped. Here is the relation in my entity ogLineItem: @OneToOne(optional = true, fetch = FetchType.EAGER) @JoinColumn(name = "LINEITEM_ID") private LineItem lineItem; Do you see something wrong? – jobe Sep 23 '13 at 21:07

0 Answers0