views:

188

answers:

3

Hello, I'm new to VisualForce, as you will obviously recognize by the following. How would one convert a jsp page into an apex page? I've included some of the most common code that I will have to deal with and need the apex equivalent. I cannot find a decent tutorial or howto and I'm not having too much luck from the VisualForce developers guide. Thanks

<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>

            <div class="contentBox">
                <h2>Upcoming Events</h2>
                <%
                    SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy");
                    if(session.getAttribute("upcoming")!= null) {

                        List<Event> upcomingList = (List)session.getAttribute("upcoming");
                        if(upcomingList!=null) {
                            for(Event event:upcomingList) {
                            String date = formatter.format(event.getDate());
                            %>
                    <p><a href="/doep/ViewEventDetail?id=<%=event.getId()%>" class="titleReg"><%=event.getEventName()%>:<br /></a>
                    <span class="stamp"><%=date %> / <%=event.getTime() %><br />
                    <%= event.getAddress()%></span>
                <%}
                        }
                    }   
                    %>

            </div>
A: 

I may be wrong, but I don't believe there is any good way to do a translation of JSP to APEX. Oracle has another technology that uses the same application services setup (AKA DAD) as APEX. This is called a PSP, or PLSQL Server Pages. The pages are loaded into the database by a program called LOADPSP. The concept is the same as JSP, it uses html and special PSP tags that define the dynamic portion of the page. CSS Style sheets may be used to define a common look and feel to the applications pages.
The LOADPSP program converts the page into a plsql procedure that uses the Oracle HTML ToolKit (OWA*, HTP, and HTF packages) to generate the html for the webpage. Procedure names are mapped into URLs by the DADs that are configured as per Apache MOD_PLSQL.

Dave
Thanks for your answer but you're thinking of a different APEX
amadib
+2  A: 

Ahmad, this looks pretty straight forward with Salesforce.com Apex and Visualforce. With most Visualforce pages you will need to have an Apex controller behind it to really do anything. Visualforce is made up of essentially a series of tag libraries so most of the heavy lifting is done in the Apex controller. In your case above you'll need to create a public list of Events via a SOQL query in your controller. Then your Visualforce page is essentially display markup. One of the cool things about Apex and Visualforce is that inherits the formatting of the field automatically. Therefore, if your Event SObject contains a date field, Visualforce will automatically format the string for you.

Here is a demo with code that may help you: Apex Search with Checkbox Results

I can only post one URL here so try googling the following for more help:

  • "Force.com Tutorial: An Introduction to Visualforce"
  • "Start Developing with Salesforce.com — Today!"

HTH

Jeff Douglas
Advanced Certified Salesforce.com Developer
Appirio, Inc.

Jeff Douglas
A: 

Thank you all for your suggestions and comments. I'm still working to get the hang of the Salesforce world. I was finally able to answer my question.

The functionality of server side scripting provided by for example JSPs, is not available on Visualforce pages. So like Jeff eluded to above, any coding would need to be done with the use of a controller.

amadib