14.01.2013 Views

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

double convertedPercentage = new Double(percentage).doubleValue();<br />

double multiplyNumber = 1 + convertedPercentage / 100;<br />

Number newSalary = employee.getSalary().multiply(multiplyNumber);<br />

employee.setSalary(newSalary);<br />

Attention: The type of the parameters is String, because that is easiest to pass<br />

from the ViewController, and it can be converted to any type you need.<br />

Attention: This code assumes that you created a View Row class for the<br />

Employees view. You can generate this class by going to the EmployeesView<br />

editor, selecting the Java category and checking the EmployeesViewRowImpl<br />

class checkbox.<br />

Attention: The Number class referenced is oracle.jbo.domain.Number, not<br />

java.lang.Number.<br />

• Publish this method to the ADF Data Control by opening the Application<br />

Module Editor, and going to the Client Interface category. Shuttle the new<br />

increaseSalary method to the right.<br />

Now you can choose between two customizations:<br />

1. Call the increaseSalary method from a button where you pass the current<br />

Employee Id and a fixed percentage of 10.<br />

2. Call the increaseSalary method from a button where you pass the current<br />

Employee Id and take the percentage from an input field on the page.<br />

If you choose 1, apply the steps from section Creating a Button that Calls the Method<br />

With a Fixed Percentage, and if you choose 2, apply the steps from section Creating a<br />

Button that Calls the Method With Percentage From Input Field.<br />

6.13.2. Creating a Button that Calls the Method With a Fixed Percentage<br />

Before we generate the button into the page, we drag-and-drop it using the JDeveloper<br />

Visual Editor, including the relevant ADF Bindings. That way we can see what it is we<br />

need to generate.<br />

Before making any customizations, ensure that the names of the used generator<br />

templates are included in the sources, as explained in the section Finding Out Which<br />

Generator Templates Are Used.<br />

• Go to the page where you want to add the button (for example Employees.jspx)<br />

in Design mode.<br />

• Go to the Data Control Palette, and find the new increaseSalary method of the<br />

Application Module.<br />

• Drag-and-drop the increaseSalary method next to the other group level buttons.<br />

• Choose Create – Methods – ADF Command Button. An Action Binding Editor<br />

dialog opens. Don't close it yet.<br />

We will now pass the current Employee Id, and a fixed value of 10 (to increase the salary<br />

with 10 percent) to the increaseSalary method.<br />

<strong>JHeadstart</strong> Developer’s <strong>Guide</strong> Generating User Interface Widgets 6- 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!