0

I've had a look at the various other discussions about this error, like for example Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable, but I'm not able to solve this error

I'm developing a primefaces web application.

I'm trying to use p:tabView. I'm defining the tabs model using the "value" attribute. Inside each tab I've defined a form, a fieldset and an outputlabel.

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:f="http://java.sun.com/jsf/core">

 <head><title>IGNORED</title></head>
 <body>
    <ui:composition template="/template/masterLayout.xhtml">
      <ui:define name="content">
        <p:tabView id="tabView" value="#{TestBean.tabs}" var="tab">
           <p:tab title="#{tab.tabId}">                 
              <h:form id="tabForm">                     
                <p:fieldset legend="FieldSet - #{tab.tabId}" binding="#{tab.fs}">
                  <p:outputLabel value="OutputLabel - #{tab.tabId}" />
                </p:fieldset>
              </h:form>                                     
           </p:tab>
        </p:tabView>
     </ui:define>
  </ui:composition>
 </body>      
</html>

When I add the 'binding' attribute to 'p:fieldset' I'm getting an error: binding="#{tab.fs}": JBWEB006016: Target Unreachable, identifier ''tab'' resolved to null. If I remove the 'binding' attribute everything works well, although I'm referencing 'tab' in other many tags.

What I don't undestand why it is not resolved in the 'binding' attribute but it is resolved in other tags like outputlabel.

Why I'm getting this error? What I'm doing wrong?

TestBean.class definition:

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean(name = "TestBean")
@ViewScoped
public class TestBean implements Serializable
{
  private ArrayList<TabBean> tabs = null;

  @PostConstruct
  public void init ()
  {
    tabs = new ArrayList<TabBean>();

    TabBean tab1 = new TabBean("Tab1");
    tabs.add(tab1);
    TabBean tab2 = new TabBean("Tab2");
    tabs.add(tab2);
  }

  public ArrayList<TabBean> getTabs()
  {
    return tabs;
  }

  public void setTabs(ArrayList<TabBean> tabs)
  {
    this.tabs = tabs;
  }     
}

TabBean.class definition:

import java.io.Serializable;

import org.primefaces.component.fieldset.Fieldset;

public class TabBean implements Serializable
{
  private String tabId = null;
  private Fieldset fs = null;

  public TabBean (String tabId)
  {
    this.tabId = tabId;
  }

  public String getTabId()
  {
    return tabId;
  }

  public void setTabId(String tabId)
  {
    this.tabId = tabId;
  }

  public Fieldset getFs()
  {
    return fs;
  }

  public void setFs(Fieldset fs)
  {
    this.fs = fs;
  }
}

Thanks

Community
  • 1
  • 1
Eduardo
  • 1,079
  • 4
  • 21
  • 49
  • Thanks for your help, BalusC. I've read what you suggested me. If I don't understand bad the problem is that I have a binding in a ViewScope bean. – Eduardo Mar 18 '16 at 09:43
  • Another problem is that p:tabView var is not available during view build time. There's physically **only one** component here which is reused during rendering. Related reading food: http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – BalusC Mar 18 '16 at 09:49

0 Answers0