Roshnara Rose

Greenhorn
+ Follow
since Nov 08, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roshnara Rose

Hi,

I would like to know how added objects are stored in arraylist.
Java passes objects by reference. So i added an object to arraylist and then set it to null. The arraylist has it.
Is pass by value happening here? Is the pass by reference is only for user defined methods?

Thanks
11 years ago
Hi,

I have got a shell script which calls a java program(BuildPage.java). I have created a thread and is starting from BuildPage.java. My intention was not to build pages concurrently as this script is calling from many places. So i have created a Thread (CreatePage.java) and started it from BuildPage.java.
In this, i'm creating a lock file in the synchronised method and removing it after build is over.
From webapplication, i'm calling the script to build the pages from a servlet. While building, the application hangs. I'm not much familiar with Threads.
Please help me to get rid of this problem. Also please suggest any different way of implementation for this.

Thanks in advance..




// ============================================


// ============================================

// ============================================



[NK: Please UseCodeTags]
Hi,

I could generate the byte[] for the jfreechart image. Right now i'm looking for an option to render this byte[] as an image in jsf page.

The code follows
JFreeChart freeChart = ChartFactory.createBarChart("", "Y Axis", "X Axis", pieDataSet, PlotOrientation.HORIZONTAL, false, true, false);
CategoryPlot categoryplot = (CategoryPlot)freeChart.getPlot();
categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
categoryplot.setDomainGridlinesVisible(true);
BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
barrenderer.setDrawBarOutline(false);
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
barrenderer.setSeriesPaint(0, gradientpaint);
ChartRenderingInfo barRenderInfo = new ChartRenderingInfo();
BufferedImage image = freeChart.createBufferedImage(300, 400, barRenderInfo);
byte[] imgByte = ChartUtilities.encodeAsPNG(image);

How i can display this byte[] as image using HtmlGraphicImage?

B/w i'm checking on the cewlof for the same. But if i can make any progress in this , that will be more appreciated.

Thanks,
I'm trying to build the UI from the bean. For that i can't use the <c:chart> tag as it offers only limited customization.
In the code i'm getting the <h anelGrid id="barGraph") and trying to add the chart as a child to it.

UIForm form = (UIForm) context.getViewRoot().findComponent("topTenForm");
UIPanel dataPanel = (UIPanel) form.findComponent("barGraph");
dataPanel.getChildren().clear();

My doubt is here

outputComponent = new UIOutput();
outputComponent.setValue(freeChart);
dataPanel.getChildren().add(outputComponent);

Can i add the JfreeChart to panelGrid like this?
I have sample codes using awt. But none from JSF. I searched for long time but didn't get some useful stuffs.
I have noted one thread in this forum but that's with jsp.
https://coderanch.com/t/414194/JSP/java/display-Buffered-Image-object-jsp

Is there anyway to use that in JSF?
in jsf, c points to the Jfree chart taglib

<jsp:root xmlns:c="http://sourceforge.net/projects/jsf-comp>

and i had used

<c:chart id="chart1" datasource="#{backBean.pieDataSet}" type="bar" is3d="false" orientation="horizontal" colors="blue" antialias="false" height="250" width="500"></c:chart>

The pieDataSet is the DefaultCategoryDataset to display the bar graph.
I could display the chart using this. Now i want more customization on the graph.

For Jfree chart support, I have included all needed jars (chartcreator, jfreechart & jcommon) in the app.

Regards,
Rose
Hi,

I have configured JFree chart for my charting purpose and could plot the bar chart using <c:chart> tag and CategoryDataset. Now i would like to customize the chart from my backing bean and display in jsf page. But i'm getting
" org.jfree.chart.JFreeChart@133c2d2 " in the page while displaying.
Following the code for generating the chart

JFreeChart freeChart = ChartFactory.createBarChart("", "Y Axis", "X Axis", pieDataSet, PlotOrientation.HORIZONTAL, false, true, false);
CategoryPlot categoryplot = (CategoryPlot)freeChart.getPlot();
categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
categoryplot.setDomainGridlinesVisible(true);
BarRenderer barrenderer = (BarRenderer)categoryplot.getRenderer();
barrenderer.setDrawBarOutline(false);
GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
barrenderer.setSeriesPaint(0, gradientpaint);
//ChartRenderingInfo barRenderInfo = new ChartRenderingInfo();
//freeChart.createBufferedImage(300, 400, barRenderInfo);
outputComponent = new UIOutput();
outputComponent.setValue(freeChart);
dataPanel.getChildren().add(outputComponent);
dataPanel.setRendered(true);

I'm pretty new to JSF. Please advice how i can display the customized graph from the bean.

Thanks in advance.
I have tried the chart display with <div> in verbatim tag but the display looks the same, no chart display. I'm not getting any clues for not displaying the chart with the JSF app.

Please share your ideas.

Also i came thru the <a4j:mediaOutput> tag for object/embed tag. Not sure how far it is helpful in this case..
12 years ago
JSF
Hi,

Now I'm using FusionCharts lib for charting.
From the above code


graph1.jsp

<jsp:directive.page import="util.FusionChartsCreator" />
<%
String chartXML = "<chart caption='Monthly Sales Summary' subcaption='For the year 2006' xAxisName='Month' yAxisName='Sales' " +
"numberPrefix='$'><set label='January' value='17400' /><set label='February' value='19800' /><set label='March' value='21800' />" +
"<set label='April' value='23800' /><set label='May' value='29600' /><set label='June' value='27600' />" +
"<set label='July' value='31800' /><set label='August' value='39700' /><set label='September' value='37800' />" +
"<set label='October' value='21900' /><set label='November' value='32900' /><set label='December' value='39800' /></chart>";

String graphCode = FusionChartsCreator.createChartHTML("FusionCharts/Column3D.swf", "", chartXML, "myChart", 600, 300, false);
%>

<%=graphCode%>

This is supposed to display the chart i want and it is displaying in an html page (when i tried with alternate js function). But while running the app, it is not displaying with jsf. The FusionCharts directory, graph1.jsp, WEB-INF and the main jsf page are in the same level in the directory structure.

I debugged with Firebug and the html code for the graph code found is

<span id="topTenForm:barGraph" style="width: 400px;">
<object id="myChart" height="300" width="600" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="always" name="allowScriptAccess"/>
<param value="FusionCharts/Column3D.swf" name="movie"/>
<param value="chartWidth=600&chartHeight=300&debugMode=0&dataXML=<chart caption='Monthly Sales Summary' subcaption='For the year 2006' xAxisName='Month' yAxisName='Sales' numberPrefix='$'><set label='January' value='17400' /><set label='February' value='19800' /><set label='March' value='21800' /><set label='April' value='23800' /><set label='May' value='29600' /><set label='June' value='27600' /><set label='July' value='31800' /><set label='August' value='39700' /><set label='September' value='37800' /><set label='October' value='21900' /><set label='November' value='32900' /><set label='December' value='39800' /></chart>" name="FlashVars"/>
<param value="high" name="quality"/>
<embed height="300" width="600" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="myChart" quality="high" flashvars="chartWidth=600&chartHeight=300&debugMode=0&dataXML=<chart caption='Monthly Sales Summary' subcaption='For the year 2006' xAxisName='Month' yAxisName='Sales' numberPrefix='$'><set label='January' value='17400' /><set label='February' value='19800' /><set label='March' value='21800' /><set label='April' value='23800' /><set label='May' value='29600' /><set label='June' value='27600' /><set label='July' value='31800' /><set label='August' value='39700' /><set label='September' value='37800' /><set label='October' value='21900' /><set label='November' value='32900' /><set label='December' value='39800' /></chart>" src="FusionCharts/Column3D.swf"/>
</object>
</span>

And it showing a white box without any graph in it. How i can show this in the jsf page? Any specific tags available in jsf for this?

Thanks in advance

Rose
12 years ago
JSF
Hi,

I'm trying to display a line chart inside a jsf page.
On click on a button, i want to show a grid containing the chart.
I can get the javascript to show the chart on the page. How i can execute that js while rendering the panel?

My code follows

<h:form id="topTenForm" rendered="#{!(quantityBean.dataPresent)}">
<h:panelGroup>
<h:panelGrid id="topTenPanel" columns="2">
<h:panelGroup id="barGraph">
HERE I WANT TO DISPLAY THE GRAPH
</h:panelGroup>
<h:panelGroup id="topTen">
<t:dataTable value="#{quantityBean.topTenRows}" var="topTen">
</t:dataTable>
</h:panelGroup>
</h:panelGrid>
</h:form>
12 years ago
JSF
Hi Pranav,

Thanks a lot.. Its working..

Regards,
Leema
Hi Pranav,

I'm great to have your reply. I did tried it both way. Now a new exception is throwing. That is like this.. What went wrong in the code.. I'm using jboss-IDE for the development..

This is at the jboss's console..

09:33:28,813 INFO [STDOUT] ejb/HelloHome
09:33:29,095 INFO [STDOUT] java.lang.ClassCastException
09:33:29,199 ERROR [[Hello]] Allocate exception for servlet Hello
javax.servlet.ServletException: Lookup of java:/comp/env/ failed
at test.web.HelloServlet.init(HelloServlet.java:64)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Hi

I'm getting the following error while running..
can anybody help ... don't know whats with this....

18:23:27,277 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:23:29,231 INFO [EARDeployer] Init J2EE application: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:25:04,716 INFO [EjbModule] Deploying Hello
18:26:07,529 INFO [ProxyFactory] Bound EJB Home 'Hello' to jndi 'ejb/Hello'
18:26:07,805 INFO [EJBDeployer] Deployed: file:/home/leema/apps/jboss/server/default/tmp/deploy/tmp3957HelloApp.ear-contents/HelloEJB.jar
18:26:49,493 INFO [TomcatDeployer] deploy, ctxPath=/hello, warUrl=.../tmp/deploy/tmp3957HelloApp.ear-contents/HelloWeb.war/
18:27:48,473 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
18:27:48,968 ERROR [JBossCacheManager] JBossCacheService to Tomcat clustering not found
18:27:48,993 ERROR [TomcatDeployer] Failed to setup clustering, clustering disabled
18:28:54,098 INFO [EARDeployer] Started J2EE application: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:33:53,327 INFO [STDOUT] java.lang.ClassNotFoundException: HelloHome
18:33:53,382 ERROR [[Hello]] Allocate exception for servlet Hello
javax.servlet.ServletException: Lookup of java:/comp/env/ failed
at test.web.HelloServlet.init(HelloServlet.java:63)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)

my files are like this..

ejb-jar.xml

<ejb-jar >

<description></description>
<display-name></display-name>
<enterprise-beans>
<!-- Session Beans -->
<session >
<description></description>
<display-name>Name for Hello</display-name>
<ejb-name>Hello</ejb-name>
<home>test.interfaces.HelloHome</home>
<remote>test.interfaces.Hello</remote>
<ejb-class>test.ejb.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</ejb-jar>

jboss.xml

<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>ejb/Hello</jndi-name>
</session>
</enterprise-beans>

jboss-web.xml

<jboss-web>
<ejb-ref>
<ejb-ref-name>ejb/Hello</ejb-ref-name>
<jndi-name>ejb/Hello</jndi-name>
</ejb-ref>
</jboss-web>

web.xml

<web-app >
<distributable/>
<servlet>
<servlet-name>Hello</servlet-name>
<display-name>Name for Hello</display-name>
<description><![CDATA[Description for Hello]]></description>
<servlet-class>test.web.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
<ejb-ref >
<description><![CDATA[Reference to Hello]]></description>
<ejb-ref-name>ejb/Hello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>test.interfaces.HelloHome</home>
<remote>test.interfaces.Hello</remote>
</ejb-ref>

</web-app>


client

public class HelloServlet extends HttpServlet {
private HelloHome home;
public HelloServlet() {
super();
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {

Context context = new InitialContext();
Object ref = context.lookup("java:comp/env/ejb/Hello");Object ob = PortableRemoteObject.narrow(ref,Class.forName("HelloHome"));
home = (HelloHome) ob;
} catch (Exception e) {
System.out.println(e);
throw new ServletException("Lookup of java:/comp/env/ failed");
}
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException {
// TODO Auto-generated method stub
System.out.println(" in dopost ");
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();

out.println("<html><head><title>");
out.println("Hello Bean");
out.println("</title></head>");
out.println("<body>");

out.println("<h1>");
out.println("Hello Bean");
out.println("</h1>");
try {
Hello bean = home.create();
String ret = bean.sayHello("Hello World String");
out.println(ret);
bean.remove();
out.println("<p>");
out.print("The ");
out.print(ret);
out.println("</p>");
} catch (Exception e) {
out.println(e.getMessage());
e.printStackTrace(out);
} finally {
out.println("</body></html>");
out.close();
}
}

}
Hi..

I'm badly in need of configuring the lomboz plugin for eclipse3.1. I'm using linux platform.I downloaded lomboz-emf-gef-jem-3.1RC2.zip and i added the contents of features and plugins folders to eclipse's corresponding folders. And appended the contents of config.ini to eclipse's corresponding file just above the 'End of file marker'. And i started eclipse. I reffered this link http://www.objectlearn.com/support/docs/installation/install.jsp. But i couldn't find out the folders in plugin as they specified in this. And moreover i couldn't find any Lomboz things under windows perspective. can any one help me to solve this..

Plz help me.. its urgent..
Hi Rajesh,

I need to use jboss as application server. And in jboss where i can put the jsp and servlet. The EJB jar i can put in server/default/depoly rt. But i need to invoke the EJB from the servlet. How it is possible.

Thanks,
Rose
Hi..

I'm just started to work in EJB 2 days back. I'm using jboss server. I'm trying with examples only. I can able to deploy an EJB by deploying jar in server/default/deploy and accessing the bean from command prompt.

I need to know how i can access an EJB from a servlet. Where i need to put servlets and jsps in jboss.

And also i want to access mySql from the EJB. How can i do that? By default it is accessing Postgrel DB. where it is located?

Hope you people can help me to clarify these bluffs...