Search code examples
jspsalesforceapex-codevisualforceforce.com

Translating JSP VisualForce


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>

Solution

  • 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.