In this lesson, we are going to see how to change the same page behavior dynamically.
For example, in our project, if we look at the functionality whenever we click on the Detail page all the patient details are showing but all are showing in Editable format, and moreover the add button is also in active stage whenever we click on Detail image in the search page.
So therefore here our requirement and our task is whenever we click on Detail logo all the items and data must be only in Read-only stage, and also the Add button must be in Disable mode.
To achieve these dynamic change in OAF pages follow the steps:
- Edit the Patient Entry page VO.
- Create one transient attribute in the VO.
Transient attribute in OAF is nothing but the attribute value which is not in the Oracle Data Base table. We know that while creating VO all the Columns of the table will be converted into Attributes or we call columns as attributes in VO, so therefore transient attribute is one which we create temporarily to display some results which will not effect data base tables.
For example, Student marks are saved in different columns but in data base assume that we are not maintaining any column for total marks sum but if we want the total value to be displayed in OAF form so therefore for that we will create on temporary or duplicate attribute value to hold total marks.
Let us see how to create a transient attribute in OAF according to our requirement:
Edit the VO as shown in the below figure:
Right click on VO and select Edit PatientEntryVO or double click on the VO to open it.
After opening the VO select the Attributes value in the left side as shown in the below figure:
Select New button which is located down to the attributes list, After selecting New button to give new attribute name, Type as Boolean, and in Updatable select a Radio Button option called Always, for example, see the below picture:
Click on Ok button later click on Apply and Ok button in View Object so that the transient attribute will be created.
After creating transient attribute now create one SPEL value basing on patient entry vo, because we need to do dynamic changes on this page only:
After creating SPEL pass this SPEL value in each and every item of a Patient Entry page region, pass the SPEL value to all the items those we want them to act as a read-only values, note that we cannot pass this SPEL value directly to region because of that reason we have to pass in each item, now the question rises where to pass SPEL value:
Pass the SPEL value in :
-> Select XML page, and in the page structure select the item.
-> In the property inspector Functional -> Read Only, here we will find True and False.
-> Remove the current existing True/False value and place the SPEL value which we created here.
pass the SPEL values to all the items and even to ADD button item.
After adding the SPEL value go to AM and add the following additional line in the AM method which we created to add patient as follows:
public void xxinsertpatient()
PatientEntryVOImpl vo= getPatientEntryVO1();
OADBTransaction trans= getOADBTransaction();
Row v_row = (Row)vo.createRow();
//the below one is the additional line code
In the Controller class add the following code, in code “ppatientid” is the parameter value of detail icon which we already seen in the previous lessons so additionally, we are adding three lines which are:
String pid = pageContext.getParameter("ppatientid").toString();
String whereclause = "PATIENT_ID='"+pid+"'";
// add the following lines
OAViewObject vo=(OAViewObject)am.findViewObject("PatientEntryVO1"); Row row= vo.first(); row.setAttribute("xxReadOnly",Boolean.TRUE);
Rebuild the code and run the page and see the output, the below figure shows the search page output and the second image shows the dynamically changed page which is actually the patient entry page:
Click on Detail Image icon in the search list:
Check out our Popular Trainings