File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes How to include an applet in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to include an applet in JSF" Watch "How to include an applet in JSF" New topic
Author

How to include an applet in JSF

Praveen Yendluri
Ranch Hand

Joined: Apr 13, 2011
Posts: 34
Hi

I want to generate graphs in facelets project. We are using JSF 2.0. We have Perspective for Java to generate graphs. in this project. So, Perspective for Java is providing an applet which i need to embed in jsf.

Could any one let me the solution?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Welcome to the JavaRanch, Praveen!

You can wrap your applet tag with the JSF "verbatim" tag and that should do it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Praveen Yendluri
Ranch Hand

Joined: Apr 13, 2011
Posts: 34
Hi Tom,

Thanka alot for your suggestion.

I have tried, but not worked out. As reference I have pasted my sample Xhtml code below. Please let know am I doing correct or not?

<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<h:head><title>JSF 2.0: Static Navigation</title>
<link href="./css/styles.css"
rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<div align="center">
<table border="5">
<tr><th class="title">Page A</th></tr>
</table>
<br/>
<h:form>
<h:commandButton value="Go to Page B"
action="page-b"/>

</h:form>
</div>
<f:verbatim>
<APPLET
CODE="TDGChartApplet.class"
ARCHIVE="PfjFull.jar"
WIDTH="750"
HEIGHT="425" >
<param name="TDGSCRIPT" value='
setUseSampleData(false);
setGraphType(20);
setDepthRadius (0);

setData (0,0,30);

setData (1,0,40);

setGroupLabel (0,"Order");


setDataRangeToExtent();
setSeriesLabel (0,"Comp");
setSeriesLabel (1,"Average Comp");

setSeriesType(getSeries(1),2);
setSeriesFillColor(0,new Color(0,255,0));
setSeriesFillColor(1, new Color(0,0,255));

setLineWidth(getSeries(1),1);
setMarkerShape(getSeries(1),3);
setAxisAssignment(0,0);
setAxisAssignment(getSeries(1),1);

setY1ScaleMinAuto (false);
setY1ScaleMin(0);
setY2ScaleMinAuto(false);
setY2ScaleMin(0);
setY1TitleString ("Number of Work Orders");
setY2TitleString ("Average Number Of Days");
setTextRotation(getY2Title(),1);
setFillColor(getY2Title(),new Color(0,0,255));

setFontSizeVC (getGroup(0),600);


'/>

</APPLET>

</f:verbatim>

</h:body></html>


Thanks in advance!!

Thanks,
Praveen
Praveen Yendluri
Ranch Hand

Joined: Apr 13, 2011
Posts: 34
Tim,

Sincere apologies for not specifying correct name.

Thanks,
Praveen
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Praveen Yendluri wrote:Tim,

Sincere apologies for not specifying correct name.

Thanks,
Praveen


I've been called worse.

You may want to try out our "Code" button on the message editor. It makes things like java code, XML, and other pre-formatted text easier to read.

I'm afraid I'm out of practice on the details of applets, although we have a forum that can help with that. The main issues I can see with your example, however, are these:

1. JSF is using xhtml. XHTML is case-sensitive, so use of upper case "APPLET" tag may not work. Actually, I don't even remember. Is it "applet" or "object" these days? Then there's the whole IE versus the Rest of the World thing.

2. You're including a multi-line script as a parameter to the applet and I'm not sure what the line breaks are going to do to the mechanism. One thing that JSF can help with, however, is making it easier to include the text. You can use EL to feed it from the JSF backing bean like this:

Praveen Yendluri
Ranch Hand

Joined: Apr 13, 2011
Posts: 34
Hi Tim,

Thanks for your suggestion!!

When I ran the above code in Eclipe IDE it was not displayed the required graph, but with the same code I can display in Netbeans 6.9.1 (with applet tag changed to small case). Is there any supporting or compatibility issues with eclipse ide.

Thanks,
Praveen
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

I think the "applet" tag is no longer the recommended tag to use for applets and may not work in all applet viewers/web browsers. You can check with the folks in our Applets forum, though.
Praveen Yendluri
Ranch Hand

Joined: Apr 13, 2011
Posts: 34
Hi Tim,

Below is my Xhtml code the has to generate bar charts using perspective for java (pfj.jar).
In this code I have used an applet to display. I am trying to set data dynamically(using <ui:repeat> tag) from back bean "myBean" in the applet. At this point it is throwing error.

Can we use jsf tags inside applet? But when I set it with static data (like (setData(0,1,30)) )it displaying graph properly and able to print bean values properly.

<?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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Facelet Title</title>
<script>
</script>
</h:head>
<h:body>
<h:form>

<!-- Just Printing Bean values -->
<ui:repeat value="#{myBean.releasedData}" var="released" >
#{released.late} #{released.good} #{released.warned}


</ui:repeat>

<applet
code="TDGChartApplet.class"
archive="PfjFull.jar"
width="750"
height="425" >
<param name="TDGSCRIPT" value='
setUseSampleData(false);
setGraphType(18);
setDepthRadius (0);
setStackedDataValueSum (true);

setDataTextDisplay (true);

<ui:repeat value=#{myBean.releasedData}" var="released" >
setData(0,0,#{released.late});
setData(1,0, #{released.good});
setData(2,0, #{released.warned});
</ui:repeat>
setDataRangeToExtent();
setSeriesLabel (0,"Good");
setSeriesLabel (1,"Warned");
setSeriesLabel (2,"Late");


setSeriesType(getSeries(1),1);
setSeriesFillColor(0,new Color(0,255,0));
setSeriesFillColor(1, new Color(0,0,255));
setSeriesFillColor(2, new Color(0,0,10));

setLineWidth(getSeries(1),1);
setMarkerShape(getSeries(1),3);
setAxisAssignment(0,0);
setAxisAssignment(getSeries(1),1);

setY1ScaleMinAuto (false);
setY1ScaleMin(0);
setY2ScaleMinAuto(false);
setY2ScaleMin(0);
setY1TitleString ("Number of Work Orders");
setY2TitleString ("Average Number Of Days");
setTextRotation(getY2Title(),1);
setFillColor(getY2Title(),new Color(0,0,255));

setFontSizeVC (getGroup(0),600);


'/>

</applet>
</h:form>
</h:body>
</html>


Error it is throwing:

javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml: Error Traced[line: 36] The value of attribute "value" associated with an element type "null" must not contain the '<' character.

Please can you assist on this?

Thank you,
Praveen

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to include an applet in JSF
 
Similar Threads
how we relate a progress bar with our program
How to generate charts using cewolf
manish
Dynamic graphs
drawing graph