JSF :: Populating A Datatable From Onetomany Collection

Apr 9, 2015

I am having a hard time trying to wrap my head around trying to get a couple of columns in a datatable populated with values from a @OneToMany collection. The concept is simple but my brain refuses to grasp it!! I will try to make this brief...

I have several forms built with primefaces 3.5 using NetBeans 8 IDE on a JBoss EAP 6.21 server, and JPA 2.1 annotations. Data is extracted from an Oracle 11 database, which consists of several lookup tables, as well as a primary table and secondary table. Using the EntityManager createQuery method I query the database, which of course returns a resultset. The query grabs all records from the primary, as well as values from 2 specific columns of the secondary database, based on search criteria entered by the user on a primefaces search form. The returned results are then iterated through, this is where I am trying to get the values from the secondary table to populate specific fields in the datatable.Here is the applicable code from the list.xhtml form containing the datatable:

<p:dataTable id="datalist" value="#{foreignPartyController.returnedSearchResults}" var="item"
selectionMode="single" selection="#{foreignPartyController.selected}"
paginator="true"
rowKey="#{item.foreignPartyId}"
rows="30"
rowsPerPageTemplate="10,20,30,40,50"
sortOrder="ascending"
resizableColumns="true"
style="overflow: auto"

[code]....

As odd as the code may look (and I will completely understand anyone cringing as to some of the coding methods I use), specifically with the ui:repeat tags nested inside the datatable tag of the list.xhtml form, I strangely do see the values from the secondary table showing up in the form showing the results in a datatable. However, when the user clicks on a specific record in the returned resultset listed in the datatable, another form is opened and populated with the values from the datatable, but the 2 fields on that form that should be populated with the 2 values I referred to before from the secondary table (i.e. policy1Num and totalPayoutAmt) do not have the values in them.

This is partly because I have those 2 fields in the editable form pointing to the managed bean of the secondary table (code from that bean not shown here), rather than the same "polNum. policy1 Num" and "totPayout.totalPayoutAmt" var I am using in the list.xhtml form. How those values are being successfully returned into the datatable of the list.xhtml form - I happened to "stumble" across the use of the "polNum" and "totPayout" vars with the "policy Payment Collection" list. I do not know how to do the same thing for those 2 fields in the editable form.how a datatable gets populated, specifically with values in a @OneToMany collection,

View Replies


ADVERTISEMENT

Appropriate Way Of Populating Collection Through Instance

Feb 23, 2015

I have a method that accepts JSONArray as parameter and returns the values of it as ArrayList Object. My question which of these ways is appropriate in populating the ArrayList object this method populates the arraylist upon creation of object (I don't know what the right term to use, but as netbeans IDE suggest, JSONArray object should be final since it was used in inner class.).

private List<String> getStringList(final JSONArray jsonArr) {
return new ArrayList<String>() {
{
try {
for (int i = 0; i < jsonArr.length(); i++) {
add(jsonArr.getString(i));
}
} catch (JSONException ex) {
ex.printStackTrace();
}
}
};
}

this second method is the usual way of populating collection

private List<String> getStringList(JSONArray jsonArr) {
List<String> strList = new ArrayList<String>();
try {
for (int i = 0; i < jsonArr.length(); i++) {
strList.add(jsonArr.getString(i));
}
} catch (JSONException ex) {
ex.printStackTrace();
}
}

What are the advantages and disadvantages between the two? like which is faster? or which consumed larger memory?

View Replies View Related

JSF :: XML Schema Into Datatable

Apr 21, 2014

I have an xml schema.. I need to display it as JSF datatable.This is my xml schema

XML FILE
<?xml version="1.0" encoding="UTF-8"?>
<shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>

[code]....

View Replies View Related

JSF :: Move Datatable Rows Up And Down?

May 22, 2014

I have a requirement like in a Rich datatable, and i have placed two links up and down in one of the column of each row, here i wanted to swap rows (move up/ down ) the rows when i click the link on a perticular row. is it possible with jsf/ java script?

View Replies View Related

Populating A LinkedList In Java?

Feb 17, 2014

I have a LinkedList class that implements a game.

I want to create a list and populate it when a LinkedList object is created .
.
The game constructor takes a word.

How do you populate a LinkedList of any type for example suppose I have a LinkedList of the Integer type, How do I fill it up with 10 integers?

View Replies View Related

JSF :: Nested Table Without Using Datatable

Apr 11, 2014

Need to create a nested table without using datatable. I am using jsp and jsf but using datatable is not allowed.

View Replies View Related

Populating Two Matrices With Method?

Sep 4, 2014

This is the method public void populateMatrices(int [][]mat1, int [][]mat2). I know how to do it for one matrix, but what do we do for the additional matrix? Here is the code I have so far.

for (int row =0; row<mat1.length;row++){
for (int column = 0; column<mat1[row].length;column++){
mat1[row][column]=1 + (int)(Math.random()*5);

View Replies View Related

Populating JList Using Database?

Jan 13, 2014

I am trying to populate a Jlist for information stored on a database. The database contains football club names, but instead of being populated with their names it just has a hexadecimal reference ( Club@183357c4 ) for each club object.

View Replies View Related

Populating A List With Data

Jul 18, 2014

I have been given a task to do, which is to create a memberList and populate it with data. The constructor has been created with me, but I am required to add code to display the memberList. I am also required to creates a method to display members.This is the method I created:

/**
* Populates the list of members.
* Displays the membership numbers and names of library members in ascending membership number order.
* The first member is selected by default.
*/
public void displayMembers()
{
initComponents();
library = new LibraryCoord();
Collection<Member> Member = library.getMembers();
memberList.setListData(Member);
memberList.setSelectedIndex(0);

[code]....

The code below TO DO is mine.What is meant to happen when I run the project is for a GUI form list to show the members of memberList. However, it does not.

View Replies View Related

JSF :: Edit / Update Row Of Datatable

Jan 23, 2014

I am implementing code of edit/update row of datatable in jsf.

package org.demo;
import java.util.ArrayList;
import java.util.Arrays;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name="order")
@SessionScoped

[Code] .....

View Replies View Related

JSF :: Datatable Not Editable Inside Of A Form

Oct 11, 2014

When I have a datatable of primefaces with paginator and its only readable and not editable, its not needed to be inside of a form, right? although I have seen it many times inside of it

View Replies View Related

JSF :: Display Just A Datatable Is Faces Request?

Jun 5, 2014

1. If we have and xhtml page and we just have a datatable to show some records through a managed bean, I think there is no validation phase, apply request values phase... so it would be a faces request but not with the lifecycle of a jsf request, right?

2. In the previous case because the normal phases of a jsf request are not going to be called, the method that will be called in the backing bean to get the records, could be called more than once although its not a normal faces request?

View Replies View Related

Java - Populating Terms Array?

Mar 18, 2015

I must convert some Java fubction to a plain "Basic", as VB6. The problem I'm facing is this: Suppose I have an array like

Java Code:

private static final int[][] Terms = {
{193, 26, 13},
{183, 29, 14},
{170, 20, 11}
}; // total 659 terms mh_sh_highlight_all('java');

How do I populate the Terms array?

Is it:

Terms[0,0]=193;
Terms[1,0]=26;
Terms[2,0]=13;
Terms[0,1]=183;
Terms[1,1]=29;
Terms[2,1]=14;
Terms[0,2]=170;
Terms[1,2]=20;
Terms[2,2]=11;

?

I'm not sure this is right... Is there a way to automate this process? What if we have arrays like int[][][] Terms? This is terrible... Is there a software tool for this?

View Replies View Related

JSF :: Selected Checkboxes Does Not Change To Unselected In Datatable

Jul 8, 2014

I used Primefaces 4.0.7.I has trouble with checkboxes, which are not change,with unselected checkboxes when I press . I mean, i selected someone from selectone menu in my bsPanel(first panel) and then the datatable fills with his/her duty.Then I select all the duties in the datatable to assign to someone else in bilgiPanel. Then duties assign this person and then i choose same person in the top panel(bsPanel),then datable seems with selected sutiesHere xhtml file;

<p:panel id="bsPanel" header="#{etiketler.personel}" collapsed="false" toggleable="true" >
<h:panelGrid id="grid" columns="2" columnClasses="colclass1,colclass2" rowClasses="rowclass1, rowclass2">
<h:outputText value="#{etiketler.personel}: " />
<p:selectOneMenu id="personel" value="#{bsView.kullanici}"
effect="fade" converter="#{entityConverter}">
<f:selectItems value="#{bsView.kullanicilar}" var="s"
itemLabel="#{s.adiSoyadi}" itemValue="#{s}"
/>

[code]....

View Replies View Related

JSF :: Enable / Disable Columns In DataTable PrimeFaces

Jul 21, 2014

I have created one dataTable in page and shown some columns but I want to show only those columns which have entries ( if any column doesn't have record then it should not be displayed on the page.) . How should I put validation on this and display table.

View Replies View Related

JSF :: How To Update Datatable After Registering User In Database

Apr 11, 2014

I have requirement, in that I am showing a Datatable, above that table i have form in that i can register a employee, after clicking on submit employee data have to be saved in the database aswell as i have to update datable, so that I can see that registered employee in that Datatable, how can i full fill this requirement. I am using jsf 2.0, ejb3.0,jpa 2.0.

@Override
public List<Employees> getallEmployees() {
System.out.println("all employee fetched");
return (List<Employees>) em.createNamedQuery("Employees.findAll").getResultList();
}

In managed bean I am calling this service as fallow in init method, and i am binding same this. employee list to UI

public String getAllEmployeesfronHr() {
this.employees = customerservice.getallEmployees();
System.out.println(this.employees.size() + "=================size of employee");
return "";
}

For every submit button click i have to query database or is there any mechanism to update List / can we use entity manager in anyway so that we can update Employee List....

View Replies View Related

Populating Properties In Object Class Using A Loop

Jun 3, 2015

I am parsing an XML file. i.e.

<people>
     <person  firstname="John" lastname="Doe"  age="50" />
     <person  firstname="Thomas" lastname="Jefferson" age="260" />
<people>
 
I have created Person.java with the following attributes:
 
private String firstName;
private String lastName;
private int age;
 
My main method parses the XML, loops through each person, and gets the attributes for each.
 
I need to create instances of my Person class. I could write something like this:
 
Person person = new Person();
for (int i = 0; i < attributes.getLength; i++) {
  if (attribute.getName(i) = "firstname") { person.firstName = attribute.getValue(i);}
  if (attribute.getName(i) = "lastname") { person.lastName = attribute.getValue(i); }
  if (attribute.getName(i) = "age") { person.age = attribute.getValue(i); }
}
 
Since my actual XML has quite a few attributes, I would rather do something like this:
 
Person person = new Person();
for (int i = 0; i < attributes.getLength(); i++) {
  person[attribute.getName(i)] = attribute.getValue(i);
}
 
This doesn't work.

View Replies View Related

Populating Array Doesn't Work Inside Constructor

Feb 24, 2014

Java Code:

import java.io.*;
import java.util.Scanner;
public class asciiFile {
int height;
int width;
Scanner input;
char[][] poop;
public asciiFile(File f) throws FileNotFoundException{ //constructor

[code]...

The constructor is supposed to take an ASCII file, take the numbers in the file, and populate a 2D array with the numbers in the file.

For some reason, the for loop I use to populate the array works outside of the constructor. When I put it in one of the methods, it runs normally. However, when I keep it in the constructor, I get the following error:

Exception in thread "main" java.lang.NullPointerException

at asciiFile.<init>(asciiFile.java:16)

at main.main(main.java:6)

View Replies View Related

Populating ArrayList Using Scanner Class Logic Error

Sep 12, 2014

My code runs and populates an arraylist. However my break statement, while stopping the loop ends up being added to the arraylist. And I'm not sure how to fix this error.

public static void main(String args[]) throws Exception
{
// declaring variables
String input = "";
// creating array list
ArrayList<String> nameList = new ArrayList<String>();

[Code] ....

View Replies View Related

Populating HashMap - Code Too Large Compilation Error

Mar 17, 2014

We are getting "Code too large" compilation error for one of our class. This class contains public String fields for label ID and value. We use this class for localization, except for English all other language labels come from .properties files.
 
The reason we are getting this error is because we have a static block in which using reflection we are populating a HashMap with all public fields and their value. The number of fields have gone up to the extinct where we are crossing the 64K limit for a static method. One of the most feasible solution was to use .properties files for English labels as well.
 
I will be calling this class MyLabels. We defined a super class for MyLabels called MyLabelsExt. And now we are adding labels into the super class instead of the MyLabels. By running some tests we confirmed that the map that we initialize in MyLables class contains all the fields from both MyLabels and MyLabelsExt class.
 
How is the 64K limit error not coming if the labels are defined in a super class. Does that mean Java is able to identify that some of the fields are coming from parent class, and that is being treated as separate from the child class. And how is the map that we initialize having all the value.

View Replies View Related

JSF :: Dialog Box Data Show In Primefaces Datatable When Click On CommandButton

Aug 5, 2014

When i click on 'Add Invoice' button open a dialog box. input data in dialog box. After click on 'Save Invoice' all the data of dialog box is render in primfaces datatable. After that click on 'Save Invoices' all data of primefaces datatable and HTML table data are store in ipsDetail and Invoice object of Managed Bean class.

XHTML file :

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">

[Code] .....

Here, Problem is ipsDetail elements NULL when click on 'Save Invoice' button in addRow() so that primefaces datatable not updated. So that i can not insert new invoice data in database table.

View Replies View Related

JSF :: Dialog Inside Datatable With Button Displays Wrong Variable Value

Nov 27, 2014

I have a bookings table where customers can view their bookings and in the table there is a button with a command button that onclick goes to the dialogue to display the variable petUpdate value but if you have 2 bookings then all the update buttons display the value of the last petUpdate in the arrayList.

DataTable with the button

<p:dataTable
id="bookingTable"
var="customerBooking"
value="#{booking.sessionBookingList}"
editable="true"
style="margin:0px 0px 20px 100px;font-size:15px;width:600px;"
>

Code in the above datatable.......The commented out output label displays the correct value for each but when the button is clicked the dialog only displays the last ones value

<p:column headerText="Check Updates" style ="width:50px;">
<!-- <h:outputLabel value="#{customerBooking.petUpdate}"></h:outputLabel> -->
<p:dialog header="#{customerBooking.petName}'s Status" widgetVar="dlg1" minHeight="60" minWidth="60" maxWidth="60">
<h:outputText value="#{customerBooking.getPetUpdate()}" />
</p:dialog>
<p:commandButton value="?" onclick="PF('dlg1').show();" style ="width:40px;">
</p:commandButton>
</p:column>

View Replies View Related

How To Choose The Right Collection

Feb 14, 2015

I have small project to be implemented in Java, which, expected the management of a parking.

The project has a class abstract Vehicle, whence derive three classes: Car, Motorcycle, Heavy Vehicles; the cost estimated time for the 3 types of vehicles are: 2€ for Cars, 1€ for Motorcycle and 5€ for H.V.

In addition, in class Ticket will be stored the arrival time of the customer and the characteristics of his vehicle.

Finally, in the class Parking(which provides 80 places available), here it should be added the various types of vehicles.

Now, I though of using an Collection, as Set.. So that they can not, two Vheicle with same license plate.

View Replies View Related

String Garbage Collection

Jul 22, 2014

I have a method

void method(){
String s =null;
String s1 = new String();
}

In this all the two strings are eligible for garbage collection?

View Replies View Related

Database Driven CD Collection App

Feb 27, 2014

I am using mysql database and I have downloaded the library also I have managed to get the database connection and query working. I need to know if I need to create separate classes to add/remove/edit items and view items? Do I need to put my database connection script in every class that I create or should I create methods for both the connection and the queries that will be called in the additional classes or methods that I have?

Below is what I have written so far and it is working, I will change the database and query soon to reflect the task I need to do because I have followed a tutorial.

Java Code:

/**
* cdCollection.java
*/
package org.com.mm00422_prototype;
//Import for the SQL package
import java.sql.*;

//Registering the JDBC driver
//Class.forName("com.mysql.jdbc.Driver");

[code]....

View Replies View Related

Garbage Collection Logs In Application

Nov 26, 2013

In my applications garbage collection logs, I see below line.

2013-11-26T10:35:45.050-0500: 5195.298: [GC 5195.298: [DefNew: 17430K->456K(19136K), 0.0102408 secs] 796185K->779211K(2668480K), 0.0103687 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
2013-11-26T10:36:10.593-0500: 5220.840: [GC 5220.840: [DefNew: 17480K->398K(19136K), 0.0100548 secs] 796235K->779153K(2668480K), 0.0101835 secs]

The last line seems half cut. Does that indicate that there is memory leak in my application? I have not seen the app throwing the out of memory error.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved