tags:

views:

90

answers:

1

My requirement is to display tables from database in Graph format and I am using fiji for the same. And on doing so I am encountering and exception, My jsp page is as follows.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:fiji="http://exadel.com/fiji"&gt;
    <fiji:columnChart id="columnChartOne" value="#{GraphBean.monthMap}" title="One-series Column Chart" barCaption="none"
                      barColors="#{GraphBean.colors}" captionX="Months" captionY="Amount" toolTipValue="{y} {name} are sold in {x}"
                      subtitle="Hardware sales per month" width="400" height="400">
        <fiji:chartData type="name" value="#{GraphBean.names}" />
    </fiji:columnChart>
</ui:composition>

My bean is as follows :

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Random;


public class GraphBean {

    private Integer data;
    private  Map<String, Integer> monthMap = new LinkedHashMap<String,Integer>();
    private ArrayList<String> names = new ArrayList<String>();
    private ArrayList<String> colors = new ArrayList<String>();
    Random rnd = new Random(new Date().getTime());

    public GraphBean() {
        super();
        generateData();
    }

    private void generateData() {
        monthMap.put("January", getData());
        monthMap.put("February", getData());
        monthMap.put("March", getData());
    }

    public Map<String, Integer> getMonthMap() {
        return monthMap;
    }

    public ArrayList<String> getNames(){
        names.add("Motherboards");
        return names;
    } 

    public ArrayList<String> getColors(){
        colors.add("#5db2c2");
        return colors;
    } 

    public Integer getData() {
        data = rnd.nextInt(50);
        return data;
    }
}

I have made entry for the bean in the faces-config.xml.

+1  A: 

In JSF, you could render the page either with facelet or with JSP (although not recommended) As far as I see, you are trying to load JSP page, while adding a facelet tag:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:fiji="http://exadel.com/fiji"&gt;
...
</ui:composition>

. If you would like to use the pages with facelet, you can download an example that is using facelet here . As you can see, the name of the pages are postfixed with .xhtml and not with .jsp.

If you would like to use JSP your page has to be:

    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://exadel.com/fiji" prefix="fiji" %>

    <html>
     <head>
      <title>enter your name page</title>
     </head>
     <body>
<f:view>
            <fiji:columnChart id="columnChartOne" value="#{GraphBean.monthMap}" title="One-series Column Chart" barCaption="none"
                              barColors="#{GraphBean.colors}" captionX="Months" captionY="Amount" toolTipValue="{y} {name} are sold in {x}"
                              subtitle="Hardware sales per month" width="400" height="400">
                <fiji:chartData type="name" value="#{GraphBean.names}" />
            </fiji:columnChart>
       </f:view> 
    </body>
    </html>

Again, I would recommend to you to use facelet, if it's a new project.

See a tutorial here

Odelya
Pssh, your JSP example is invalid. There's still an `</ui:composition>` there and you'd like to wrap the JSF components in a `<f:view>`. Points for nailing down the problem though: you cannot mix legacy JSP with its sucessor Facelets.
BalusC
@BalusC - I edited my answer. I just copied his code too quickly
Odelya
Debarshi DasGupta
hey can you specify which all jars are needed for fiji charts?
Debarshi DasGupta
It says on their site:http://www.exadel.com/fiji/README.txt
Odelya
@ Odelya ....thanks again I am encountering this exeception do you have a solution **The absolute uri: http://exadel.com/fiji cannot be resolved in either web.xml or the jar files deployed with this application**
Debarshi DasGupta
do you have the jar in your application?
Odelya
yes I have all the jars......
Debarshi DasGupta
flamingo-service-jsf-1.6.1-SNAPSHOT.jar amf-serializer-1.6.1-SNAPSHOT.jar common-annotations.jar commons-beanutils.jar commons-collections.jar commons-digester.jar commons-logging.jar el-api-1.0.jar el-impl-1.0.jar fiji-api-1.0.0.jar fiji-ui-1.0.0.jar jsf-api-1.2_09.jar jsf-facelets-1.1.14.jar jsf-impl-1.2_09.jar jstl-1.2.jar laguna.jar richfaces-api-3.2.2.CR3.jar richfaces-impl-3.2.2.CR3.jar richfaces-ui-3.2.2.CR3.jar standard.jar
Debarshi DasGupta
Can you post a new question for that?
Odelya
okies.I will post a new question.
Debarshi DasGupta