Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using selectOneMenu inside a dynamically generated tabView causes Exception, when new Tab is added dynamically #918

Closed
radorybar opened this issue Feb 27, 2018 · 10 comments
Assignees
Milestone

Comments

@radorybar
Copy link

radorybar commented Feb 27, 2018

  • Overview of the issue
    Using selectOneMenu inside a dynamically generated tabView causes Exception, when new Tab is added dynamically.
javax.el.PropertyNotFoundException: Target Unreachable, identifier 'currentHazard' resolved to null

viewId=/app/ra/raEdit.xhtml
location=.....................\app\ra\raEdit.xhtml
phaseId=APPLY_REQUEST_VALUES(2)

Caused by:
javax.el.PropertyNotFoundException - Target Unreachable, identifier 'currentHazard' resolved to null
at org.apache.el.parser.AstValue.getTarget(AstValue.java:74)

/app/ra/raEdit.xhtml at line 93 and column 132 value="#{currentHazard.origin}"

piece of code, which causes an error:

<b:tabView>
    <b:tab title="#{not empty currentHazard.id?currentHazard.id:'new'}" value="#{rAController.getHazardsOfTypeByHazardTypeCode('Mechanical hazards').hazards}" var="currentHazard" varStatus="tabStatus">
        <h:outputText value="#{currentHazard.type.code} - #{currentHazard.origin.code}" />
        <b:selectOneMenu value="#{currentHazard.origin}" rendered="#{not empty currentHazard}">
            <f:converter converterId="hazardOriginConverter" />
            <f:selectItem itemLabel="(Please select)" itemValue="#{null}" />
            <f:selectItems value="#{currentHazard.type.hazardOrigins}" var="hazardOrigin" itemValue="#{hazardOrigin}" itemLabel="#{hazardOrigin.code}" />
        </b:selectOneMenu>
    </b:tab>
</b:tabView>

<b:commandButton action="#{rAController.addNewHazard(rAController.getHazardsOfTypeByHazardTypeCode('Mechanical hazards').hazardType)}" value="Add Hazard" disabled="#{rAController.viewOnly}"/>

Without selectOneMenu this piece of code works, so iteration variable currentHazard should be resolved correctly after controller action, which creates new hazard item.

  • Motivation for or Use Case
    After lot of tries I've replaced Pootsfaces tabView with Primefaces tabView and that solution is working.

piece of code that works:

<p:tabView value="#{rAController.getHazardsOfTypeByHazardTypeCode('Mechanical hazards').hazards}" var="currentHazard" >
    <p:tab title="#{not empty currentHazard.id?currentHazard.id:'new'}">
        <h:outputText value="#{currentHazard.type.code} - #{currentHazard.origin.code}" />
        <b:selectOneMenu value="#{currentHazard.origin}" rendered="#{not empty currentHazard}">
            <f:converter converterId="hazardOriginConverter" />
            <f:selectItem itemLabel="(Please select)" itemValue="#{null}" />
            <f:selectItems value="#{currentHazard.type.hazardOrigins}" var="hazardOrigin" itemValue="#{hazardOrigin}" itemLabel="#{hazardOrigin.code}" />
        </b:selectOneMenu>
    </p:tab>
</p:tabView>

<b:commandButton action="#{rAController.addNewHazard(rAController.getHazardsOfTypeByHazardTypeCode('Mechanical hazards').hazardType)}" value="Add Hazard" disabled="#{rAController.viewOnly}"/>
  • BootsFaces Version(s)

1.2.0

  • Browsers and Operating System

No browser dependent issue.

  • Reproduce the error

Probably any selectOneMenu inside a dynamically generated tabView will not work, but that is only a guess.

  • Related issues

Not known.

  • Suggest a Fix

No Idea.

@stephanrauh
Copy link
Collaborator

@radorybar It seem I need your help. I've tried to reproduce your bug, but I didn't managed yet. I've committed and pushed my reproducer in the BootsFacesWeb project (see this commit: TheCoder4eu/BootsFacesWeb@bb39b12).

Please have a look at it. Does my reproducer work on your machine? If not, can you give me a hint what's missing?

Thanks in advance!
Stephan

@radorybar
Copy link
Author

@stephanrauh Thank you for your reproducer. I extended it that way, so it corresponds to the reported issue. I wanted to attach it here as a ZIP file, but I got 'We don't support that file type' error. As a workaround I added TXT extension to each file.
Domains.java.txt
Hazard_.java.txt
HazardOrigin_.java.txt
HazardOriginConverter_.java.txt
HazardType_.java.txt
Issue918.java.txt
issue918.xhtml.txt

stephanrauh added a commit to TheCoder4eu/BootsFacesWeb that referenced this issue Mar 1, 2018
@stephanrauh
Copy link
Collaborator

I've integrated your changes with the showcase and pushed the commit. Thing is, I still don't see any bug. Can you close or download the repository and check whether I accidentally solved it without knowing?

Things I tried:

  • I converted the project to Java 8.
  • I switched from Mojarra to MyFaces. (If you do that too, you'll have to remove HighFaces from the pom.xml).

Things I did not try:

  • Run the project on an JavaEE application server. Instead, I replaced the @nAmed and @Inject annotations by an older API.

It's possible that the problem only occurs on an application server, or maybe even only on a specific application server. Which one are you using?

@radorybar
Copy link
Author

I use TomEE application server. I'll try showcase with different server.

@stephanrauh
Copy link
Collaborator

I forgot to mention it, but we've designed the showcase to run on a simple Tomcat. That's why I've ported the annotations to the older JSF API. It's possible that my modifications cause the demo to run flawlessly on TomEE, too.

BTW, starting with BootsFaces 2, we're going to embrace JakartaEE (formerly known as JavaEE) full-heartedly. I'm under the impression that the number of Spring users using JSF is dwindling.

@radorybar
Copy link
Author

radorybar commented Mar 1, 2018

Well, with GlassFish and WildFly reproducer works. It really looks like a problem specific to TomEE.

@stephanrauh
Copy link
Collaborator

I've managed to reproduce the issue with TomEE 7.0.2.

@stephanrauh
Copy link
Collaborator

@radorybar It seems you've found a major bug. It's just strange that it doesn't manifest in the other application servers. I've uploaded a new version of BootsFaces 1.2.1-SNAPSHOT to Maven Central (see #369 on how to get it). Would you mind to test whether the bug has been solved?

@radorybar
Copy link
Author

With provided snapshot the problem disappeared,

@stephanrauh
Copy link
Collaborator

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants