How to Create a Simple ASK Application with Oracle JDeveloper 10.1.3
How to Create a Simple ASK Application with Oracle JDeveloper 10.1.3
This topic describes how to use JDeveloper to create a simple Ask application. These applications are deployed on an Ask server, which enables messaging devices to interact with web applications. JDeveloper 10.1.3 does not provide design-time support for creating Ask applications. However, there are workaround solutions for the same.
Contents
- Introduction to Ask
- Example of Ask Messaging
- Creating a Simple Ask Application Using JDeveloper
Introduction to Ask
Ask Server is a component that enables messaging devices to interact with web applications. It provides a way for users of messaging devices to ask for information, hence the name.
Ask Server Architecture
Oracle Application Server Wireless presents a framework and a runtime environment for developing wireless and voice applications accessed through a browser-based device such as a device with a WAP or XHTML browser, or through messaging-protocol-based devices such as mobile phones with SMS. Ask Server is the wireless component that enables the messaging protocol-based devices to access these wireless applications.
Conventionally, the entry point into an application server is through the HTTP protocol. This limits applications built on an application server to only clients with web capability. This server restriction is a problem for mobile market users, because the vast majority of mobile users does not have web access. These users, however, are almost certain to have some kind of message capability (such as e-mail or SMS). With the introduction of Ask Server, applications can also be accessed through messaging protocols other than HTTP, such as e-mail or SMS. The developers the build only the application logic, while Oracle Application Server Wireless establishes the proper connection, performs session management, and interprets user requests. An application is invoked the same way regardless of which protocol handles the incoming requests, offering complete transparency to application developers to allow access to their services.
Example of Ask Messaging
Here's an example of how a device user can access a web application.
To access a Stock Quote application, a user having an SMS-enabled phone can do the following:
- Create a message and specify the destination address provided by the application portal, for example, 223.
- Specify the text stk orcl in the message body.
Note: The text stk is a short name to identify a stock quote application and orcl is the argument required by the application.
The server then processes the message and sends back the result with another message.
Creating a Simple Ask Application
This topic takes you through the steps required to create a "Hello World" application from within JDeveloper. You need to perform the following tasks:
- Create an Empty Application and Project
- Create a new JSF JSP File
- Create a Java Bean
- Create a Managed Bean
- Add ADF Components to the JSF JSP File
- Test the JSF JSP File
- Add a Render Kit and a View Handler to the ADF Faces Configuration
- Add Ask Render Kit Implementation and ADF Share as Part of the Library
- Create a Deployment Profile
- Deploy the Application
Create an Empty Application and Project
Create an application and project.
- Open the New Gallery by choosing File
New.
- In the New Gallery, in the Categories tree, select General.
- In the Items list, double-click Application.

- In the Create Application dialog, enter HelloApp as the application name and click OK.

- In the Create Project dialog, enter HelloPrj as the project name and click OK.

Back to the main task
Create a new JSF JSP File
Create a JSF JSP file.
- In the Applications Navigator, right-click the project you just created and select New.
- In the New Gallery, expand the Web Tier node and select the JSF category.
- In the Items list, double-click JSF JSP.

- On the Welcome page, click Next.
- On the Web Application page, select Servlet 2.4\JSP 2.0 (J2EE 1.4) and click Next.
- On the JSP File page, select JSP Document, enter Hello.jspx as the filename, and click Next.

- On the Component Binding page, select Do Not Automatically Expose UI Components in a Managed Bean, and click Next.
- On the Error Page Options page, click Next.
- On the Tag Libraries page, use the
button to move ADF Faces Components and ADF Faces HTML from the Available Libraries list to the Selected Libraries list, and click Finish.

- On the HTML Options page, click Next.
- On the Finish page, click Finish to create the JSF JSP file.
Back to the main task
Create a Java Bean
Create a Java Bean, to store the input name.
- In the Applications Navigator, right-click the project you just created and select New.
- In the New Gallery, expand the General node and select the JavaBeans category.
- In the Items list, double-click Bean.

- In the Create Bean dialog, enter HelloBean as the name, select java.lang.Object from the Extends dropdown list, and click OK.

-
In the source editor for the HelloBean.java file, add the following code after the bean constructor:
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
private String name;

Back to the main task
Create a Managed Bean
Create a managed bean inside the ADF Faces configuration.
- In the Applications Navigator, expand the Web Content tree under the project you created.
- Expand the WEB-INF tree and select the faces-config.xml node.
The structure of the faces-config.xml file will appear in the Structure window.

- In the Structure window, right-click Faces Config and choose Insert inside Faces Config
managed-bean.
- In the Create Managed Bean dialog, enter Hello as the name and mypackage.HelloBean as the class, and click OK.

- In the Structure window, expand the managed bean node and right-click Scope.
- Choose Insert after Scope
managed-property.
- In the Create Managed Property dialog, enter name as the name and java.lang.String as the class, and click OK.

- In the Structure window, right-click the managed property node and select Properties.
- In the managed-property Properties dialog, enter #{param.name} as the value and click OK.

Back to the main task
Add ADF Components to the JSF JSP File
Add ADF components to the JSF JSP file.
- In the Applications Navigator, double-click Hello.jspx.
- In the Structure window, delete the jsp:output and html nodes.

- Right-click f:view and choose Insert inside f:view
ADF Faces HTML Html.
- Right-click afh:html and choose Insert inside afh:html
ADF Faces HTML Head.
- Right-click afh:head - Title 1 and choose Properties.

- In the Head Properties dialog, enter Hello App as the title property and click OK.

- In the Structure window, right-click afh:html and choose Insert inside afh:html
ADF Faces HTML Body.
- Right-click afh:body and choose Insert inside afh:body
ADF Faces Core.
- In the Insert ADF Faces Core Item dialog, select Form and click OK.

- In the Structure window, right-click af:form and choose Insert inside af:form
ADF Faces Core.
- In the Insert ADF Faces Core Item dialog, select OutputText and click OK.

- In the Structure window, right-click af:outputText - outputText1 and choose Properties.
- In the OutputText Properties dialog, enter Hello (with a trailing space) as the value property and click OK.
Note: The trailing space is required to differentiate between the static output text Hello and the subsequent output parameter, which we will pass to the application.

- In the Structure window, right-click the output text node and choose Insert after af:outputText - Hello
ADF Faces Core.
- In the Insert ADF Faces Core Item dialog, select OutputText and click OK.
- Right-click af:outputText - outputText2 and choose Properties.
- In the OutputText Properties dialog, delete the default value and click Bind.
- In the Bind to Data dialog, in Variables navigation tree, expand JSF Managed Beans and Hello, and select name.
- Click the
button to create an EL expression using the variable and click OK.

- In the OutputText Properties dialog, click OK.

Back to the main task
Test the JSF JSP File
Test run the application.
- Choose Run
Run Hello.jspx.
This launches the default web browser and displays the text Hello when no parameter value is passed to the page.

- Append ?name=John to the URL in the address bar and press Enter.
The web browser will now display the text Hello John.

Back to the main task
Add a Render Kit and a View Handler to the ADF Faces Configuration
Configure a Renderkit onto faces-config.xml.
- In the Applications Navigator, select the faces-config.xml node.
The structure of the faces-config.xml file will appear in the Structure window.
- In the Structure window, right-click the managed bean node and choose Insert after managed-bean - Hello
render-kit.
- In the Create Render Kit dialog, enter oracle.adf.async as the ID and oracle.adfinternal.view.faces.ask.renderkit.AsyncRenderKit as the class, and click OK.

- In the Structure window, Double-click the application node.
- In the application Properties dialog, enter oracle.adfinternal.view.faces.ask.application.AsyncViewHandlerImpl as the view handler.

Back to the main task
Add Ask Render Kit Implementation and ADF Share as Part of the Library
Add the Ask render kit implementation as part of the library.
- In the Applications Navigator, right-click the HelloPrj node and choose Project Properties.
- In the Project Properties dialog, in the navigation tree, click Libraries.

- On the Libraries page, Click Add Library.
- In the Add Library dialog, click New.

- In the Create Library dialog, click Add Entry.

- In the Select Path Entry dialog, navigate to wireless/lib under the JDeveloper home directory, select ask-adf-faces-impl.jar, and click Select.

- In the Create Library dialog, click OK.
- In the Add Library dialog, click New.
Note: We need to repeat some steps to add the ADF Share library.

- In the Create Library dialog, click Add Entry.
- In the Select Path Entry dialog, navigate to BC4J\lib under the JDeveloper home directory, select adfshare.jar, and click Select.

- In the Create Library dialog, click OK.
- In the Add Library dialog, click OK.
- In the Project Properties dialog, click OK.

Back to the main task
Create a Deployment Profile
Create a deployment profile for the application.
- From the main menu, choose Run
Deploy New Deployment Profile.
- In the New Gallery, expand the General node and select the Deployment Profiles category.
- In the Items, double-click WAR File.

- In the Create Deployment Profile -- WAR File dialog, enter HelloApp as the name and click OK.

- In the WAR Deployment Profile Properties dialog, in the navigation tree, expand the File Groups node, expand the WEB-INF/lib node and select Contributors.
- On the Contributors page, select the ADF Common Runtime, Adfshare.jar and Adfshare.jar checkboxes, and click OK.

Back to the main task
Deploy the Application
Deploy the application.
- From the main menu, choose Run
Deploy 1 HelloApp.deploy.
The HelloApp.war file will be created under the deploy directory within your project directory.
You can now use this war file to deploy the application on the default OC4J server.
For information on how to deploy the Ask Server to non-Oracle application servers, please refer to How To Deploy Ask on Supported Application Servers
Back to the main task
|