Table with Data from Two POJO Bean Data Controls - jdeveloper

JDev 11.1.1.5.0
Use case:
Display a table where the first row will contain values from one POJO Bean data control and the second row will contain values from another.
I have managed to display the first row from one bean data control, now I want to show the second row with the other.
Hope the use case is clear.

Have a pojo that returns a collection that combines the data from the two pojos into a single record/object.
Then create a table where you put two fields in each column and show the details of the record that way.

Related

Hibernate shows different ID than DB

I have three database views that are mapped in Hibernate as entities.
The entities are in a parent-child relationship (1 parent (A), 2 children(B & C)).
One of the children views (B) uses Oracle's dbms_utility.get_hash_value() to calculate its ID.
This is because it does a UNION over several tables that use different ID sequences and thus the IDs from there may not be unique.
I now have the very puzzling effect that a simple entityManager.find(B.class, id) cannot find the appropriate row.
When I look at the children through a loaded parent (A) entity, I can see that the ID shown in B is completely different from the one in the database. If I use this ID with entityManager.find(B.class, hibernateId), Hibernate finds the appropriate entity.
The database, on the other hand, only returns a value when using the ID shown in the ID column there (and not with the ID Hibernate shows).
Child entity C does not use the hash function and does not show this peculiar behaviour - which means the hash must be responsible.
Does anyone have an idea why?
We found the reason:
Child view B used all of its (content containing) columns as a string concatenation for the hash function.
This included date fields, which were not explicitly formatted when creating the string.
So, when Hibernate selected from the view, it obviously used another format than SQL Developer and thus produced completely different (but consistent) IDs.
Explicitly formatting the used date fields removed the problem.

Spring mvc form submit not binding/updating the children objects [of list type] properly

I have a data model that is something like this:
I have one parent entity A and it has one children of list type B. In order to display the data on JSP page, i am passing the object of entity A as model attribute..
I am able to display all the properties of entity A by binding the spring PATH attribute of the field. I have one section in JSP in which I am displaying the table of property (of type entity B) as it contains the multiple elements in the list of type B by iterating the elements using jstl for loop. Till this point everything is working as expected.
We have one functionality on JSP to add the new rows in the table of property type B. I have written one JS method to add the new row in table and also increment the index of the spring path attribute by 1. i.e. if the existing row path points to propertyB[0].name, then the newly added row's path will point to propertyB[1].name.
When I add a new row in the table and also update the existing row in the table. Upon form submission, I am getting the updated value of existing row in the controller but I don't get the newly added row as new element in controller.
What I need to do to get the newly added element in the object.
get the id from A.
get the data from the newly added B
send to controller by ajax
in the controller you can update database;
return an object in json in ajax;
judge the update is right or wrong;
if right use jquery to show the newly B ,if error,alert some something

Custom NSTableViewHeaderCell

I've created a custom NSTableViewHeaderCell class but I still have one issue with separators: How know if I am drawing the last column header or not?
Actualy I don't want to draw a separator for the last column but I didn't found a way to know it is the last one.
Thanks for your help
Since you're creating a subclass of NSTableHeaderCell, create one more property on it for a NSTableColumn. You can set this property as you create and set an instance of your subclass for each of your table's columns.
Now that your subclass instances know the table columns to which they belong, they can use this to determine the table view. From the table view, you can get an array of table columns, and if you compare a given table column to the lastObject value of that array, you should be able to tell if your header cell belongs to the last table column.
If you choose to enable reordering for your table columns, you may have some more coding to do, but this should get you started.
Good luck to you in your endeavors.

Using UltratreeView (Infragistics TreeView) control

Hello All
I am using infragsitics tree view control.I have one stored procedure that returns 2 tables
1.Parent Table
2.Child Table
Currently i m Binding the treeview on the basis of these 2 tables by using loops wherein i take one row of the master table, create one node , find the associated records in child table and add it under the Parent node.
This method works fine when there are few records.
But it really takes a hell lot of time when there are high number of records.
Is there any way to directly assign datasource to treeview ? without traversing through any loops manually? such that we just need to provide 2 tables containing master and child records as the datasource and the treeview manages it automatically and binds the data
Please help..
Thanks in advance
Take a look at this sample http://help.infragistics.com/Help/NetAdvantage/WinForms/2010.2/CLR2.0/html/WinTree_Displaying_WinTree_with_Columns_in_Grid_Style.html
You can bind the data to the grid, and as long as you define the parent\child relationship the grid will be able to display master and child records.

TableAdapter to return ONLY selected columns? (VS2008)

(VS2008) I'm trying to configure a TableAdapter in a Typed DataSet to return only a certain subset of columns from the main schema of the table on which it is based, but it always returns the entire schema (all columns) with blank values in the columns I have omitted.
The TableAdpater has the default Fill and GetData() methods that come from the wizard, which contain every column in the table, which is fine. I then added a new parameterized query method called GetActiveJobsByCustNo(CustNo), and I only included a few columns in the SQL query that I actually want to be in this table view.
But, again, it returns all the columns in the master table schema, with empty values for the columns I omitted.
The reason I am wanting this, is so I can just get a few columns back to use that table view with AutoGenerateColumns in an ASP.NET GridView. With it giving me back EVERY column i nthe schema, my presentation GridView contains way more columns that I want to show th user. And, I want to avoid have to declare the columns in the GridView.
When you add a new query to a given TableAdapter, it is going to assume the schema in which it is attached to, which is why you are getting blank values for the columns you don't want.
Since you mentioned having already created the procedure, what you need to do is use the Server Explorer to connect to the database and simply drag that stored procedure over into your XSD work area. What this will do is create a separate QueryAdapter that will have just the columns you specified (still strongly typed) and you can bind/interact with your GridView using that QueryAdapter instead.
Is the strongly typed dataset used in another query that returns all the rows from the table?
What you could do is create a dataview using the strongly typed dataset and expose a data table for your DataGridView.
I'm not sure what your requirements are totally, but this example should help you:
DataView dv = new DataView(ds.<Your_Table>);
// This will create a new data table with the same name,
// But with only two columns from the original table.
// This could then be bound to your data grid.
DataTable dt = dv.ToTable(false,
ds.<Your_Table>.<Your_Column1Column>.ColumnName,
ds.<Your_Table>.<Your_Column1Column>.ColumnName);
Just delete the columns you don't want at run-time before you bind to your Gridview. The underlying class is still just a DataTable after all.

Resources