I have 2 View objects :
1- ViewObject1 - Based on entity1 and entity2.
2- ViewObject2 - Based on entity1
Scenario:
I am creating a new row in entity1 using ViewObject2.
Expectation:
I want that the ViewObject1 should also have a newly created row as both are based on entity1.
You should try re-querying ViewObject1, after commit.
Related
I have Master table(M1) and detail table(D1). The detail table(D1) has 2 fields, seq1(foreign key of M1), seq2(foreign key of another table say M2). The M1 and D1 table has one to many relationship. The M2 table has 6 fields say seq2 field1 field2 field3 field4 field5. The below is the table in detail.
M1
seq1 fieldM1 fieldM2 fildM3
M2
seq2 field1 field2 field3 field4 field5
D1
seq1 seq2
In my page I have a master form(M1) and detail table(D1). onClick of addChild the new detail rows can be added. In the detail table within the page I am showing 5 fields. 3 listBoxes and two readOnly textBoxes. All the data for the details table is getting from the M2 table.
Here are my business scenarios:
on change of any of the listBoxes the remaining 4 fields should be populated automatically by retrieving from the M2 table and the seq2 of D1 should be updated from the M2 table.
Here is my question:
1) Can I do this in a declarative approach?
Is there any better approach to create the ADF businessComponents. Please provide me enough details because I am new to ADF.
For more details please find the below screen shot.
Yes, you can do this declarative.
You can use list of values attribute in your ViewObject declaration.
LOVs can update several attributes in your detail VO.
Here is a short instruction:
http://atadf.blogspot.com.by/2013/06/how-to-define-list-of-values-for-view.html
To do so you have to add a valueChangeListener function on the LOV that will trigger the refresh.
e.g:
<af:selectOneChoice simple="true" id="userSelectOneChoice"
valueChangeListener="#{myScope.mybean.getRefreshData}"
autoSubmit="true">
<f:selectItems value="#{myScope.mybean.myList}"
id="userSelectItems"/>
</af:selectOneChoice>
You can calculate the data you want to display in this valueChangeListener as it will be trigger when a specific value is selected :
public void getRefreshData(ValueChangeEvent valueChangeEvent){
String selectedItem= String.valueOf(valueChangeEvent.getNewValue());
//Refresh my data below
}
Once the data is refresh you need to trigger a partial rendering of the table to allow the newly refreshed data to be displayed.
To do so add a partialTriggers="userSelectOneChoice" on the parent element of your table.
I have two models Model A and Model B. Model A hasMany Model B.
So now I want to build a paginated table in a View about Model A. And there I want a column, where a specific field of Model B is shown as comma separated list.
Imagine Model A is named Group and Model B is named User.
Group hasMany User
Now I want a table of the groups like
id | name | user
1 | first group | User 1, User 2, User 3
But I donĀ“t want to use a foreach within the View, it should be a string already in the array.
You can use the Model::afterFind() callback and build the string in your model and add it to the result set. In the view just use it like echo h($result['Model']['your_field_list']).
Is there a way by which I can programmatically update a select options list of LineItems?
I am trying to create Line Items from data provided by site administrators.
If you refer to http://178.79.128.76/coronet/node/78, you will see 4 types of data: The Viewing date, The Viewing options, Add to cart button and Show Times.
The Show Times data is unique for each product. Each entry consists of a date and one or more time(s).
The Viewing Options is a line item and I am trying to populate it with data extracted from the Show Times field in the following format:
Viewing Date 1 + ShowTime 1
Viewing Date 1 + ShowTime 2
Viewing Date 2 + ShowTime 1
Just for demonstrating my objective, I populated the example data above in my Viewing Options Line Item using hook_form_alter - they don't actually work when you select and attempt to add the product to.
You can have your tables set up with LineItem table, a ViewDate table and a ShowTimes table. That will allow you to have a ViewDate collection with a foreign key to the LineItem, and a ShowTimes collection with a foreign key to the ViewDate.
In my MVC 3 project, I am looking to select a row in a table displaying values from a database, choose a radio button representing a value and press "Confirm". I then want a row to be added to a ClientPayments table with the payment amount as the radio button value (and the other values in the other columns of ClientPayments). I also want the status in an Invoices table to change to "Confirmed".
Here's a link to a screenshot to illustrate what I want to do.
I have all the models and the views created, but I am not sure how to select the row and use the radio buttons to update the DB.
This is one of the radio buttons I have coded:
Private Lesson (1 Hour) #Html.RadioButton("InvoiceAmount", "640", true)
Any assistance would be greatly appreciated.
If you have something like #Html.RadioButton("InvoiceAmount", LineId, true) (where LineId is the key value from model) then you will get the selected row in your Post action. From there you can either add it to your client payment object, and do whatever else you need to do!
I have a MVC application in which I need to display the data from 3 tables. I am using entity model for it. Out of these, in 2 I have made the association:users and payment table.
And 3rd table month_<monthid> is created every month to store the users to whom the magazine is sent. The table name month_<monthid> is generated dynamically by selecting the month so in order to fetch the data I have used ExeuteStoreQuery. For small amount of data the listing is fast but for large amount it is very slow.
Now I have created a class to bind to grid which will include all the fields from the 3 tables to display.
But here when I am getting the large volume of data about 12000 then it is taking about 30 min to go through the loop and assigning the data to the class object and then adding to the list of the result which is finally binded to telerik grid.
I am hereby attaching the sample code using a link. Is there any direct way to bind the query result of joined tables to grid instead of going through the loop and preparing the list for the model class I think that will save time.
The code block of preparing the list using the Executestorequery is under the function GetuserList().
foreach (var r in result)
{
Result objresult = new Result();
var paymentresult = from sub in dtpayment.AsEnumerable() where sub.Field<int>("user_id") == r.user_id select sub;
if (paymentresult.Count() > 0)
{
objresult.amount_paid = paymentresult.FirstOrDefault().Field<decimal>("amount_paid");
objresult.magzine_id = paymentresult.FirstOrDefault().Field<int>("magzine_id");
}
objresult.address=r.address;
objresult.email=r.email;
objresult.name=r.name;
objresult.user_id=r.user_id;
objresult.month= smonth;
lstresult.Add(objresult);
}
This code block of for loop is taking very time where I am using ExceuteStoreQuery.
But I have observed that simply by joining the users and payment table using LINQ query to get all the 12000 records i.e no involvement of month table the result is appearing faster.
So,can you suggest any way to improve the performance of my application?
Also include the database structure with the sample code.
Below is the link to sample
http://sampletestone.s3.amazonaws.com/magzine.7z?AWSAccessKeyId=AKIAINHDRCMKC5GUSNFA&Expires=1303583399&Signature=8o8Wn6UNjbEl3dIyipAX9xH29Hg%3D
supriya
Nobody in the world wants to see 12,000 records. You should look at implementing paging & searching functionality.