JSF :: Creating Primefaces 4.0 Charts From Database Objects
Jul 27, 2014
I'm trying to create a simple bar chart from integer values (measuring number of bulldozers) stored in a mySql DB, in the following schema:
Integer rigId PK;
Integer rigQty;
Date recordDate;
String country FK;
I want to plot the date on the x-axis and quantity on y-axis. I can't seem to find any examples of how to render charts from a database. I just find the generic Primefaces 4.0 examples which uses static data like this:
private void createCategoryModel() { // category chart
categoryModel = new CartesianChartModel();
ChartSeries boys = new ChartSeries();
boys.setLabel("Boys");
[Code] ....
I'm really not sure how to adapt the above to a database method nor have any web searches produced useful examples. I tried something like this, but how to find examples or the type of methods I need to use to create a bar graph from Db values:
@ManagedBean(name = "chartb")
@SessionScoped
public class BarChartBean {
private final Map<Integer, Map<String, Number>> rigNums = new HashMap<>();
// private final Map<Integer, Map<String, Number>> HorasOrcadasPorFunci = new HashMap<>();
private CartesianChartModel cartesianChartModel;
[Code] ....
View Replies
ADVERTISEMENT
Jun 3, 2014
I have 4 Primefaces bar charts which sometimes renders, sometimes not. In one of them, I inject a http user session attribute and use it to render the chart (the idea is to show only the data that corresponds to the (logged in) user department).
There are 4 session beans which I'm using the javax.enterprise.context.RequestScoped. Sometimes, the Glassfish destroys the instance as expected, but sometimes not.Based on Exception below, how can I resolve it?
The xhtml below shows the main code for only 2 of the 4 bar charts:
<p:tab title="Horas de Treinamento (por Funci)" closable="true" >
<p:barChart id="horasBars" value="#{chartHorasFunci.modelHoras}"
legendPosition="ne"
orientation="horizontal"
seriesColors="AA5555, 00438F"
xaxisLabel="Horas" yaxisLabel="Funcis"
title="34 Horas de Treinamento (Orçado/Realizado) por Funci"
[Code] .....
The Exception:
SEVERE: Error Rendering View[/capacitacao/capacitacao/index.xhtml]
javax.el.ELException: /WEB-INF/include/capacitacao/capacitacao/List.xhtml @145,38 value="#{chartHorasFunci.modelHoras}": org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke private void br.com.bb.upb.diage.atb.capacitacao.beans.ChartHorasFunci.initialize() on br.com.bb.upb.diage.atb.capacitacao.beans.ChartHorasFunci@3e9c727c
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
[Code] .....
View Replies
View Related
Nov 5, 2014
how to use a Primefaces TabView for input.
I have found this link that implements the behaviour of the TabView. It basically says to make my own Tab model.
But I want each tab to contain something like this:
I tried adding the inputTexts in my Tab model but it doesn't work, I guess I was way too optimistic :P
The only reason I want this is because I don't know how many tabs I need. It's totally dynamic, the number of Lectures is added on demand.
View Replies
View Related
Mar 20, 2014
public class demo
{
Public class static void main(String[]args) {
//Creating a variable that will be a reference to the object
Peoples person_one;
[Code] ....
I have assembled this code below that has a void method which will creat a new object. Problem I encounter is that in
Create_object(person_one);
the person_one has an error saying not initialized. I'm jus trying to learn on my own ways here and practice so may know what's wrong with this? I know I can use a return object from methods but what about this approach?
View Replies
View Related
Dec 30, 2014
I'm trying to create complex Character objects. Each object has a name, and for each object with the same name, they share some of the same initial data. However, there are also some bits of data that are given to the object when it's created. For example, an "Elephant" always starts out having a weight of 500, but its position is determined when it's created. Any of these values may later be changed during runtime.
class CharacterStaticParameters {
int weight;
int numberOfFeet;
int numberOfEyes;
[code]....
For example, whether I should try to use words other than 'static' and 'dynamic', or a nicer word than 'parameters'?
View Replies
View Related
Aug 17, 2014
So I'm still trying to get to grips with Java, and like to understand exactly why I'm doing something, so that I am not just regurgitating the code, If I want to create an object from class "Apples", I would use the following, right?
Apples MyAppleObject = new Apples();
From what I understand, MyAppleObject is the new object name, new -> creates a new instance of it in memory, and Apples() is the onCreate method that is called
So question 1: (just a quick aside question) Can I create an object without calling Apples()? i.e.
Apples MyAppleObject = new;
Question 2: - PARTLY SOLVED - I discovered that (Button) is a way of typecasting, so I understand that line a little better. What I don't understand is why we don't need to initialize the object with "new"
I've now looked at a bit of android development and xml and those declarations are all together different, and I'm not sure why. I haven't found a single explanation for the difference in format.
Java Code:
Button Add;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Add = (Button) findViewById(R.id.button1); mh_sh_highlight_all('java'); So the Button object is declared above the onCreate method, but initialized afterwards I guess....
But instead of using Button Add = new Button() they use Add = (Button) findViewById(R.id.button1);
Question 3:
then In XML they use the following:
Java Code:
public*static*void*main(String[] args){
*********
********// Creates a DOM object in memory. Now you can access
********// data in the xml file
*********
********Document xmlDoc = getDocument("./src/tvshows5.xml"); mh_sh_highlight_all('java');
Once again, why didn't they have to use : Document xmlDoc = new Document()
View Replies
View Related
Sep 14, 2014
I want to make a program where users are prompted to enter a username and a password and have these two values create a new instance of the Object User. But I'm not sure where to start.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
createUser();
[Code] ....
how to take username + password and put it into an object.
View Replies
View Related
Jun 13, 2014
Java Code:
class GenericQueue<E> {
private LinkedList<E> list = new LinkedList<E>();
public void push(E element) {
list.addFirst(element);
}
public E pull() {
return list.removeLast();
[code]...
Is a constructor required to create an object, if one of its instance or class variables haven't been instantiated? Like private String string;
View Replies
View Related
Mar 16, 2014
I want to create a simple app that takes a name from the console then compares the name to a small phone book,when the name matches another name it will return the associated phone number.
I have a small contacts class which has name and number fields,Then I have a phone book class which populates an array with 4 contact objects that I can compare the entered number against.
here is my contacts class
public class Contact
{
String name;
int number;
[Code].....
In the main method I am just trying to print out one of the fields for one contact to see if I can actually access it to compare it to the name entered.Its saying "MaryJones" cannot be resolved to a type.I'm guessing I cant create all that code in the constructor?
View Replies
View Related
May 25, 2014
I've been trying to write a program for some time now, but im encountering problems while trying to complete it. The program has a student class and a course class (set up with some info about the class, like #, professor name, course title, course time). Now, i have a text file in the workspace, and i have to import the data from the textfile, and thats just what i did, but then there is an option which allows the user to delete a course only by inputing the course number, and when he does that, the program outputs the course's name, and confirms the deletion of the course (From the student's record, i created a vector for that and imported all the courses from the text file). But how can i let the program know what's the name of the course when the user inputs the course number ???
When the data is read from the file, objects should be created and added to the student's course record. <- i think here's where i messed up ? i imported the data, but how can i actually make them objects before adding them into the vector ?
PHP Code:
public static void main(String[] args) throws IOException
{
Scanner scan = new Scanner(System.in);
Vector Record = new Vector();
try {FileReader filereader = new FileReader("CLASSES.txt");
BufferedReader bufferedreader = new BufferedReader(filereader);
String test = "";
while(test != null)
{
Record.addElement(test);
test = bufferedreader.readLine();
} mh_sh_highlight_all('php');
View Replies
View Related
Apr 29, 2014
How do we cache objects in EJB 2.
My requirement is i need to get data from the database for the first time and retain in cache it throughout the application life.
View Replies
View Related
Aug 20, 2014
What is the best choice to program like an applet i mean easy with creating multithreading or drawing objects etc.
View Replies
View Related
Sep 9, 2014
I'd like to create my own Table Model to handle data from an SQLite database using JSwing, but I'm having difficulty. How to confirm the following:
-- A table model is an object that contains methods for manipulating data in the table, right?
If that's the case, then how should I create a Table Model to handle data coming from a database. From what I understand...
My custom Table Model needs to subclass AbstractTableModelI then override 3 methods from AbstractTableModel (getRowCount(), getColumnCount(), getValueAt())
As it relates to drawing data from a database, how should I be thinking about this problem (i.e. creating a Table Model that can work with a database)?
View Replies
View Related
Nov 23, 2014
I would like to import database to the Java pane and connect objects to each other and want to display their information as visually. How can i do.
View Replies
View Related
Dec 24, 2014
I want to create few forms in our project. I searched in web, All are PHP form Generator only not for any JSP. I could see one JSP form Generator Site. But the Content will store it in their Server. How to create Feedback form in JSP which will store the Data in Database directly.
View Replies
View Related
Jul 25, 2014
Really need some simple and complete example on how to extends components (graphically and functionally) for primefaces 5.
For example I can't figure how to add custom attributes to existing component or define default values for existing attributes.
Is there any tutorial or a basic common way to achieve this goal or each component have to be extended in its way?
View Replies
View Related
Dec 31, 2013
I would like to create this type of chart with Primefaces (or another JSF API), what is the best component to use to do this:
[URL] .....
View Replies
View Related
Dec 23, 2012
i am having issues using the primefaces file upload, i have it set up, very much the same as the example version but it does not work, i never get the successful message and also where does it store the file once uploaded ?
heres my code so far :
web.xml
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
[Code]....
View Replies
View Related
Mar 22, 2015
i bought a theme from themeforest but the primefaces conflicts with the js of the theme. Is there any way to fix this conflict without changing all the js?
View Replies
View Related
Jul 27, 2014
I am currently working on a project where I need to return data from a database over RMI to a client who requests it. Some of the fields in the Data Object can not be seen by the client so I need to create another object to send over the network instead. The method I use is this...
public static SerializableObject createSerializableObjectFromDataObject(DataObject dataObject){
SerializableObject serializableObject = new SerializableObject();
serializableObject.setField(dataObject.getField());
serializableObject.setAnotherField(dataObject.getAnotherField());
return serializableObject;
}
Is there a better way of doing this? I am creating many subclasses DataObject which all require this static method to be implemented and I can't push it into the superclass because each one needs custom behaviour.
View Replies
View Related
Mar 22, 2014
I'm having some problems styling the PrimeFaces upload tag <p:fileUpload /> in my application.
In my xhtml code I have the following:
<p:fileUpload id="fileUpload" fileUploadListener="#{filters.upload}"
allowTypes="#{filters.uploadTypes}" invalidFileMessage="#{filters.uploadBadType}"
sizeLimit="#{filters.uploadSize}" invalidSizeMessag="#{filters.uploadBadSize}"
update="fileUpload fileTable filterTab uploadMessage hiddenNum hiddenPhoto uploadError footer
namePhotSystem checkOverwrite"
description="Select Text File" disabled="#{filters.fileuploadDisabled}" fileLimit="1"
fileLimitMessage="You are only allowed to upload one file at a time"
styleClass="fileUploadClass" label="Choose the File to Upload" auto="true" />
This all works correctly, both the AJAX update and on the server, but I'm unable to get the button or buttons displayed in the way I need.
By including the following in my CSS:
.ui-fileupload.fileUploadClass {width:428px;}
.ui-icon-plusthick {display:none;}
.ui-button-text {width:200px; height:20px;}
the first sets the width of the button bar, and by looking at the HTML code generated by PrimeFaces, I discovered that the second hides the "+" to the left of the "Choose" button, which here has been replaced by the text "Choose the File to Upload". However, this text is displayed on two lines, with the word "Upload" on the second. I want the whole text to be on one line, but no matter what I do, I cannot get this to work properly. The third line of my CSS code does indeed reduce the height of the button, but the width does not work at all, and the last part of the text is simply lost. How do I put all the text on one line and adjust the width of the button?
Another question is that when I remove the auto="true" attribute from the tag, which I had originally, the "Upload" button is displayed to the right of the "Choose" button, and when a file is chosen but not yet uploaded, it is displayed below the button. This is a capability that I might still want, however, I am unable to style the display, and in particular the progress window to the right of the file name and size. All the files I want to upload are relatively small text files, and I want to adjust this window or even hide it completely. How is this done?
Incidentally, because the files are all quite small, I have disabled the display of the "Cancel" button, so either only the "Choose" button is shown, or the "Choose" and "upload" buttons.
View Replies
View Related
Nov 19, 2014
Currently I am having difficulties styling a particular prime faces element in a JSF application for work. I'm tasked with giving the ui a styling and color scheme acceptable to our project design. However I am finding myself unable to "hook" a particular pf element with an ID so that I can proceed with styling a imported .css file.
I'm trying to style the commandLink button to display in Orange 20px font with Italic but when I inspect the element in chrome after being rendered It doesn't even show its style linked to the assigned ID. The class style for mainMenuItem is being applied to the commandlink but is immediately over written by ui-widget. I'm trying to style that one single component(override/replace ui-widget with the properties in the #loggedInUserID)
Current .XHTML code and the css file has been linked with
<h:outputStylesheet library="css" name="masterPW.css"/>
<div class="mainMenuItem"><p:commandLink id="loggedInUserId" styleClass="maserPW.css" value="#{loginController.userFullName}"/>
</div><!--End of mainMenuItem-UserID div -->
[Code] ....
View Replies
View Related
Oct 2, 2011
<p:commandButton> of primefaces is not working but that same code working with <h:commandButton>Login bean is present with all valid getter and setter with loginAction
public String loginAction(){
if(userid.equals("ashok")&&
password.equals("admin")){
return "success";
} else {
return "login";
[code]....
View Replies
View Related
Jul 28, 2014
I am developing one form in jsf/primefaces. I have two inputText(inputMask) for e.g moble number and telephone number. I want to restrict the user to put only one of these two fields . That means if user starts putting value in mobile no. then telephone no. field should be disabled and if user starts putting value in telephone no. then mobile no. field should be disabled.
how should I do this.
View Replies
View Related
Aug 13, 2014
I have an JSF that uses primefaces accordion snippet. However I want to populate the information from each tab from a seperate webpage that would also have accordion snippet in it. I can do this on a single page no problem, but the length of the program (webpage) is getting to the point that it is unmanageable.
The code I have:
<p:layoutUnit position="center">
<p:accordionPanel activeIndex="null">
<p:tab title="Burglar">
<h:outputText value= "Burglar"/>
<p:accordionPanel activeIndex="null">
<p:tab title="Skills">
<h:outputText value= "Skills"/>
[Code] ....
What I am after:
<p:layoutUnit position="center">
<p:accordionPanel activeIndex="null">
<p:tab title="Burglar">
<h:outputText value= "Burglar"/>
<p:accordionPanel activeIndex="null" url="burglar.xhtml">
</p:accordionPanel>
[Code] ....
How to get this to work... I am sure that it has something to do with my url but not sure how to fix it and I can not find anything on the web on how to do this.
View Replies
View Related
Apr 9, 2014
I am new to jsf i have been given a task to create a tree structure in jsf but cant use richfaces and primefaces. I need a complete project for reference as i am to totally new to this.
View Replies
View Related