Hi I've a Employee and Dept Table EO and VO created with ViewLink. Now I've a API that I will be calling to save this record.
I've created a jsff and when I drag the Employee instance in jsff as ADF Form and Run it, it create the Label without the InputText. Later I used createinsert but if I dray the Empoyee CreateInsert it only displays the Input text for Empoyee attributes and If I use the createinsert of dept the dept attributes input text is visible.
1) What is the way in which I can make both employee and dept inputtext visible?
2) As I will be accessing this VO's in my java code and process them to call the API for insert, is it recommended to uses CreateInsert operation? If not whats the best way?
You can combine the two createInsert operations into a single button:
https://blogs.oracle.com/shay/entry/doing_two_declarative_operatio
Related
I am using Oracle with Oracle Forms builder (Middleware) both 11gR2. I am creating a system for purchasing records. I have the following 2 tables.
(a) product (master) : prodid(PK), prodname ...... etc.
(b) purchase (detail) : prodid(FK), quantity, ...... etc.
My plan: All the product details will be in the product table. purchase table will be used only to input purchase information. This table can't input any new product. If any new name, that info will have to be input into product table first. This way I can reduce duplicate names.
Now I am having difficulties relating to prodname (name of the product) column in the form.
I created forms using the purchase table only. This table does not have the prodname (because I put this field in product table) column. But during data entry, they need to see the product name !
So I created text item (tabular, database - no). Then I created LOV, attached to text item, input the prodid in prodid field in the form. LOV part is fine.
I run the form. click the text item, LOV appears, select a name, click OK. product name, product id, etc. appears in their fields as it should be. LOV is working fine. Now I can only input data but having difficulties updating. I mean if I input a name (LOV) in the text item, press execute query, shows records from the database but names in the text item disappear. Since the name is not here, it's not comfortable to update.
I think LOV is not the good idea here. May be I need to use PL/SQL in a trigger somewhere.
But I could not figure it out. I searched google but no luck. Is there anyone who can give me any idea or some example code/trigger please.
Since the product name is an non-database item, when execute query runs, the field is cleared and since no column is assigned to that field, it doesn't repopulate.
The usual way to populate this field is to have a function which returns the product name based on the id that is pressed and call the funtion in POST-QUERY trigger.
Basically it's a pretty simple task but I was having difficulties due to the lack of my experience. However, what I have done is -
create the text item (name : product_name) in the canvas
set properties for the product_name (database : No, .... etc as needed).
Create a block level POST-QUERY trigger and write the PL/SQL block to populate the field. For example, I wrote the following.
BEGIN
SELECT prodname INTO :purchase.product_name
FROM product WHERE product.prodid = :purchase.prodid ;
END ;
That's it and when perform execute_query in the form, it will bring the product name from another table. - Query problem is solved.
Now create an LOV using product table to bring the product name and product id.
Associate this LOV to the product_name text item. So whenever you need to input information about a purchase, just use the LOV to populate the product name field. And then input the subsequent fields as well.
This way both of my issues (query and data entry) are resolved.
I did this according to the suggestions given by Sathya and a video (6 minutes) from the youtube at https://www.youtube.com/watch?v=0nqldnGt8KA.
Thanks to Sathya and youtube.
I have an MS Access Parent form, with two sub-forms (both linking to the same table)
I am trying to use the first subform as a navigation aid (in datasheet mode) and the other sub-form is used for data entry.
What Works:
- Currently I can add new person images easily from within subform1 and subform2 refreshes once I save the record.
What is not working
- Subform 2 is unbound to the person ID, so when I try to create a new record from within subform 2 the new record is not associated with the active person record.
Any Idea how this can be made to work better. (I am using a field on the main form (imageidLink) to link Subform2's master field.
Sample database can be downloaded here
I suppose the subform2 has [per_id] too:
Edit the default value property of per_id field in subform2, and put this expression:
=Forms![Person].form![per_id]
Then when you create a new record on subform2 it will be associated to active person record.
What i need today is the following:
I have built a form, and i have several tables where that form can write to, how can i make this selectable upon opening the form? Im thinking that basically, before opening the form, i should choose in another form the table to write to, the thing is, the list of tables to write to is not fixed, i have a form that is used to create tables.
For example, i create table x and table y and table w, which are equal in structure and field names and everything, it just changes the table name itself and the values in the fields. how do i tell the form i have that it must write on table x until closing the form and then after closing, when i am to open again, it asks again which table to write to and writes to it until i close the form. Then i decide to create table u and the next time i open the form, table u must be in the list, how feasible is this and how should i approach it?
I already have a table that communicates with the form for creating a new table, hence, keeping a record of every table created, so, i can get the name of the table i want to write to, my problem now is how to change the origin of control in the form, can this be done from code?
On opening of the form you can loop through the tables collection DAO.TableDefs
and fill a listbox with the tableDeft's names.
When the user selects a table name, you set the form's record source to the table name.
You could possibly look into creating a list with a query something like:
SELECT MSysObjects.Name
FROM MsysObjects
WHERE (Left$([Name],1)<>"~")
AND
(Left$([Name],4) <> "Msys")
AND (MSysObjects.Type)=1
ORDER BY MSysObjects.Name;
MSysObjects can get you a list of objects in the database.
Keep in mind, if you have a backend that supplies the tables via linked table manager, you will need to use this:
SELECT Name
FROM MSysObjects
WHERE Databse <> '';
Using this method you can populate a control using this query as the record source. Then, you can prompt the users direction and handle each table specifically and more explicitly.
I am new working with ADF and Business component
I have a table with a columm with the department ID. This table is filled from another JSF page
I want to show the department name instead of the department Id
I have Business component with the view from my department table.
But I dont know how to show the department name instead de id in the adf table
My adf table is read only
you can create an LOV.Here you can select the type of attribute you need to display for the user externally(DNAME in your case) and type of value you need to store internally(DNO in your case) depending on the selected display value by the user.
Refer this link for LOV creation
http://techblogoracle.wordpress.com/2013/10/14/how-to-create-list-of-values-lov-in-oracle-adf/
Create a LOV in your VO for that property! Then you have two possibilities: 1- Reinsert your table in your page 2- Insert (re-insert) only the attribute that you need as a read-only column in that table!
To display the name of a department instead of the departmentId, create an LOV on the departmentId attribute in the view object that the ADF table is based on, pointing to the department view object.
To update your existing read-only table, remove the departmentId attribute from the JSF, and re-add it. Make sure that the new attribute is an "ADF select one choice." After the column has been added, select the select one choice drop down, and change the read-only attribute to true.
<af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"
label="#{row.bindings.DepartmentId.label}"
required="#{bindings.Employees_VO1.hints.DepartmentId.mandatory}"
shortDesc="#{bindings.Employees_VO1.hints.DepartmentId.tooltip}"
id="soc1" readOnly="true">
If you run this page now, it should display the name of the department, instead of the id, while still being read-only.
How to show departmentName instead of departmentId using an LOV - ADF
If you're in the same taskflow or you share Data Controls and you don't want to change your VO to be based on two EOs, you can add a Transient attribute with the name, you will populate the value in the page that fills the data. Using LOVs it's too much of a headache. If the LOV list is big you will have performance issues that you introduce trying to solve a problem in a wrong way.
You can add referenced attributes to your VO.
So create a VO that is based on Emp and Dept together.
For example see the video here: https://blogs.oracle.com/shay/entry/whenvalidateitem_trigger_in_ad
use lov or use groovy Expression if number of values is not more than 2 or 3 values
usage : #{row.code eq 'A' ? 'Approved' : 'Rejected' }
I have an excel sheet with information about each employee. I keep getting new updated spreadsheet every month. I have to create a database managing cases related to the employees. I have a database and the bounded form already created for the cases which also contain emp info fields. What I am trying to do is to only type in the emp id in the form and want the form to look up in the spreadsheet(which can be a table in the cases db) and populate other fields in the form and that information can go into the cases db. Can this be done?
Assuming the Employee information is available within the current database, perhaps in a linked (Excel), table there are a number of ways to approach this, one of which is:
Create a form based on the Employees table, showing the fields that you are interested in auto-populating
Delete the RecordSource of the form
Delete the ControlSource for each of the controls on the form. You need to do this otherwise they will all initially display with the error #Name?
Set the Locked or Enabled property of these controls to Yes or No respectively, so that the information they will display will not be editable
Add a, for example, Combo Box to the form; you can accept the third option in the Controls Wizard to help you populate this. You need the EmployeedID as the first column, but can add additional columns
Delete the Embedded Macro that Access creates (or Macro for Access 2003 or earlier) for the AfterUpdate event
Click the build button for this event (...) and create some code.
Here is some code I used with my sample Staff Database:
Private Sub cboStaff_AfterUpdate()
Me.RecordSource = "SELECT StaffID, Title, FirstName, Surname FROM " _
& "tblStaff WHERE StaffID = " & Me.cboStaff
With Me
.txtStaffID.ControlSource = "StaffID"
.txtTitle.ControlSource = "Title"
.txtFirstName.ControlSource = "FirstName"
.txtSurname.ControlSource = "Surname"
End With
End Sub
Whenever the user selects a staff (or employee) member from the combobox this will retrieve the data from the table and populate the various controls on the form. These controls will not be editable as they will be locked or not-enabled. (You can also set the Allow Additions and Allow Deletions properties of the form to No, but Allow Edits needs to remain as Yes, otherwise the combobox won't work.)
This code can be improved. In particular, to only set the RecordSource and ControlSource s once.
Obviously I am not aware of the specifics of your database, and there are other ways to approach this.
Added If, however, the RecordSource for the form is some other table that you are hoping to populate with some details from the Employees table then, instead of changing the RecordSource and ControlSource as indicated, you could use ADO (in the AfterUpdate event of the combobox) to create a RecordSet containing a single row (the chosen employee's details) and set the values (the Text) of controls on the form to the values from this recordset. As I say, there are a number of ways to approach this.
Added In response to:
"The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship...."
I don't know your precise set-up but I can tell you why this is happening. The default behaviour in Access is that, for a bound form, if a change is made to any one of the bound fields, then an attempt to navigate away from the record will cause Access to save the record.
Is the form bound when it doesn't need to be? Or have you set the ControlSource of a control to a field when it doesn't need to be? If this is not the case then:
In the BeforeUpdate event of the form you can set the Cancel argument to True to prevent the update (or insert). However, this will prevent ANY new record from being inserted. You can either have a Button that the user needs to click to explicitly save the record, or, in the BeforeUpdate event, test some condition with If to decide whether you will allow the insert (or update) or to stop the record from being saved (by setting Cancel = True).