1

Below is the code where i am facing the issue, i am not getting the output of the graphs. Kindly help me.

My XHTML code

<?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:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:tr="http://myfaces.apache.org/trinidad">    

    <h:body> 
    <h1>Director Screen</h1>  
    <tr:document>
        <tr:form>       
                <tr:chart value="#{chartBean}" type="pie" />
            <tr:chart value="#{chartBean}" type="bar" />
            <tr:chart value="#{chartBean}" type="circularGauge">
        </tr:form>
    </tr:document>
    </h:body>
</html>

Java Code

package com;

import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.apache.myfaces.trinidad.model.ChartModel;



@ManagedBean(name = "chartBean")
@SessionScoped

public class ChartBean extends ChartModel {

        @Override
    public List<String> getGroupLabels() {
        List<String> groupLabels = new ArrayList<String>();
        groupLabels.add("Java");
        groupLabels.add("Linux");
        groupLabels.add(".NET");
        return groupLabels;
    }

    @Override
    public List<String> getSeriesLabels() {
        List<String> seriesLabels = new ArrayList<String>();
        seriesLabels.add("Love it");
        seriesLabels.add("Hate it");
        return seriesLabels;
    }

    @Override
    public List<List<Double>> getYValues() {

        List<List<Double>> chartValues = new ArrayList<List<Double>>();
        // Fill the groups
        for (int i = 0; i < getGroupLabels().size(); i++) {
            List<Double> numbers = new ArrayList<Double>();

            // fill the series per group
            for (int j = 0; j < getSeriesLabels().size(); j++) {
                numbers.add(100* Math.random());
            }
            chartValues.add(numbers);
        }
        return chartValues;

    }

}
Reporter
  • 3,897
  • 5
  • 33
  • 47
Vinay
  • 51
  • 1
  • 1
  • 4

3 Answers3

1

It's mandatory to have a <h:head> in the template right before <h:body>. That's where all the JSF 2.x scripts and stylesheets end in. I won't be surprised if the <tr:chart> has some JS/CSS dependencies.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I tried to add element in my jsp but I am getting following error : No tag "head" defined in tag library imported with prefix "h" – Shekhar Aug 29 '11 at 12:43
  • Then you're not using JSF 2.0 and you'd probably need to import the styles manually. Read the Trinidad documentation for details. – BalusC Aug 29 '11 at 12:44
0

I had a similar problem and solved it by adding the following lines to web.xml:

<mime-mapping>
   <extension>svg</extension>
   <mime-type>image/svg+xml</mime-type>
</mime-mapping>
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

I was unable to get the graph in xhtml file, so i copied the same in jsp and got the graph.

Vinay
  • 51
  • 1
  • 1
  • 4