question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Diagram : elements displayed using "toString()" if facet contains conditional (rendered) blocks

See original GitHub issue

Describe the defect Say you want to customize how each element is displayed in the diagram by using “<p:outputPanel rendered=…” with the appropriate condition for each element.

If the facet only contains blocks like that with no unconditional block, then the facet displays element using “toString()” instead of the panel contents (even though the condition to render them is true)

Reproducer I’ve attached primefaces-test from your repository, including a simple test bean and facelet showing this issue primefaces-test.tar.gz

Environment:

  • PF Version: 8.0
  • JSF + version: Mojarra 2.2.20
  • Affected browsers: ALL

To Reproduce Steps to reproduce the behavior:

  1. Load “testView.jsf” in the attached sample

  2. Elements’ “toString()” is used for display, see: diagram_wrong

  3. Place whatever contents inside the facet but outside the panel, even a simple empty “span” will suffice

  4. Reload the page

  5. The diagram displays just ok, see: diagram_ok

Expected behavior “rendered” conditions should be evaluated even if there is no contents outside any “rendered” conditioned block

Example XHTML This makes the facet to be displayed wrong

    <h:body>
        <p:diagram value="#{testView.model}" var="elem" style="height: 100vh">
            <f:facet name="element">
                <p:outputPanel rendered="#{not empty elem.name}">
                    <h:outputText value="#{elem.name}" />
                </p:outputPanel>
            </f:facet>
        </p:diagram>
    </h:body>

But this, makes it work. Note that I have only added an empty “span” outside any “rendered” block

    <h:body>
        <p:diagram value="#{testView.model}" var="elem" style="height: 100vh">
            <f:facet name="element">
                <span />
                <p:outputPanel rendered="#{not empty elem.name}">
                    <h:outputText value="#{elem.name}" />
                </p:outputPanel>
            </f:facet>
        </p:diagram>
    </h:body>

All elements in the model have a non-empty name attribute Example Bean

@Named
@ViewScoped
public class TestView implements Serializable {

    private DefaultDiagramModel model;

    @PostConstruct
    public void init() {
        model = new DefaultDiagramModel();
        Element elementA = new Element(new ElementData("A"), "20em", "6em");
        Element elementB = new Element(new ElementData("B"), "10em", "18em");
        Element elementC = new Element(new ElementData("C"), "40em", "18em");
        model.addElement(elementA);
        model.addElement(elementB);
        model.addElement(elementC);
    }

    public DiagramModel getModel() {
        return model;
    }

    public static class ElementData {
        private final String name;
        public ElementData(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public String toString() {
            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                    "Curabitur efficitur ante mauris, vel ultricies neque lacinia et. " +
                    "Nullam urna erat, ullamcorper a nulla nec, auctor consequat erat. In sed mollis mi. " +
                    "Cras tristique ac orci sed luctus. Ut eu gravida lectus. Aenean dignissim, turpis convallis facilisis vestibulum, " +
                    "odio sapien tincidunt tortor, et lobortis erat quam sed felis. " +
                    "Praesent scelerisque nibh eget tempor egestas. In vitae arcu lectus. Nulla facilisi. " +
                    "Vestibulum quis cursus lorem, et mattis nisl. Ut posuere elit eget libero imperdiet consectetur. " +
                    "Nullam eu ornare tellus. Donec bibendum sapien maximus leo suscipit, sed varius sem malesuada. " +
                    "Maecenas vehicula ac ipsum non efficitur. Donec vitae fringilla quam, in congue neque. " +
                    "Pellentesque vel sem a lacus sagittis accumsan.";
        }
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stolpcommented, Jun 25, 2020

This is one of the best documented issues I have seen here in a long while. Just wanted to point that out.

0reactions
mikiomacommented, Jun 25, 2020

Thank you very much everyone 😃 For the comments and the quick fix!!!

I Appreciate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

23 Using Chart Components - Oracle Help Center
This chapter describes how to use the ADF Data Visualization chart components to display data in charts using simple UI-first development.
Read more >
JavaScript Search Framework Events - Coveo Documentation
The following diagram displays the sequential flow of initialization events. Handling Initialization Events. You must register all initialization event handlers ...
Read more >
XPath and XQuery Functions and Operators 3.1 - W3C
The functions and operators defined in this document are contained in one of several namespaces (see [Namespaces in XML]) and referenced using ......
Read more >
Lightning Aura Components Developer Guide
A facet is any attribute of type Aura.Component[]. Use this type as a placeholder for a block of markup. The body attribute is...
Read more >
Seam - Contextual Components - JBoss.org
java. Most Seam application use session beans as JSF action listeners (you can use JavaBeans instead if you like). We have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found