翻译 JSP VisualForce

发布于 2024-08-21 06:28:42 字数 1319 浏览 10 评论 0原文

我是 VisualForce 的新手,您会通过以下内容清楚地认识到这一点。如何将jsp页面转换为apex页面?我已经包含了一些我必须处理的最常见的代码,并且需要等价的 apex 代码。我找不到像样的教程或操作方法,而且我从 VisualForce 开发人员指南中也没有太多运气。谢谢

<%@ 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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甚是思念 2024-08-28 06:28:42

Ahmad,对于 Salesforce.com Apex 和 Visualforce,这看起来非常简单。对于大多数 Visualforce 页面,您需要有一个 Apex 控制器才能真正执行任何操作。 Visualforce 本质上由一系列标签库组成,因此大部分繁重的工作都是在 Apex 控制器中完成的。在上面的情况下,您需要通过控制器中的 SOQL 查询创建事件的公共列表。那么您的 Visualforce 页面本质上就是显示标记。 Apex 和 Visualforce 的一大优点是自动继承字段的格式。因此,如果您的事件 SObject 包含日期字段,Visualforce 将自动为您设置字符串格式。

这是一个演示,其中的代码可能会对您有所帮助: 带复选框结果的 Apex 搜索

我只能在此处发布一个 URL,因此请尝试搜索以下内容以获取更多帮助:

  • “Force.com 教程:简介
    到 Visualforce”
  • “立即开始使用 Salesforce.com 进行开发!”

HTH

Jeff Douglas
高级认证 Salesforce.com 开发人员
阿皮里奥公司

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.

听风念你 2024-08-28 06:28:42

我可能是错的,但我不相信有什么好的方法可以将 JSP 转换为 APEX。 Oracle 还有另一种技术,它使用与 APEX 相同的应用程序服务设置(又名 DAD)。这称为 PSP 或 PLSQL Server 页面。这些页面由名为 LOADPSP 的程序加载到数据库中。这个概念与 JSP 相同,它使用 html 和特殊的 PSP 标签来定义页面的动态部分。 CSS 样式表可用于定义应用程序页面的通用外观。
LOADPSP 程序将页面转换为 plsql 过程,该过程使用 Oracle HTML ToolKit(OWA*、HTP 和 HTF 包)生成网页的 html。过程名称由根据 Apache MOD_PLSQL 配置的 DAD 映射到 URL。

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.

天气好吗我好吗 2024-08-28 06:28:42

感谢大家的建议和意见。我仍在努力掌握 Salesforce 世界的窍门。我终于能够回答我的问题了。

由 JSP 等提供的服务器端脚本功能在 Visualforce 页面上不可用。正如杰夫在上面所回避的那样,任何编码都需要使用控制器来完成。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文