简单portlet jsp页面流程问题

发布于 2024-07-16 04:36:14 字数 502 浏览 4 评论 0原文

我是 Java portlet 的新手,并且正在尝试在相当基础的层面上了解这些东西是如何工作的。

我现在对如何在我的 portlet 中拥有多个“视图”感到困惑。 假设我的 portlet 将用于 CRUD 操作。 为了简单起见,我想象当用户第一次查看 portlet 时,他们将看到一个包含数据库中所有记录的表。 然后,用户可以单击一条记录,该记录将在 portlet 中显示一个新页面,其中包含用于更新记录的表单。 添加记录的方式大致相同。 这里没什么令人震惊的...

在哪里控制用户如何在不同视图之间导航,以及在哪里在用户可能执行的不同操作(更新、添加、删除等)之间切换?

我在网上查了一下,发现了大量的“hello world”portlet 教程,但没有多大帮助。 我发现了许多其他更高级的教程,并且适合我正在做的事情,但它们似乎都使用了一些底层框架,如 Struts、JSF 等。

我想知道如何仅使用一个使用 JSP 呈现视图的基本 portlet。

I'm new to Java portlets, and am trying to get a handle on how these things work at a fairly basic level.

I'm confused now about how to have multiple "views" in my portlet. Let's say my portlet will be used for CRUD operations. For the sake of simplicity, I'm imagining that when a user first views the portlet they'll see a table with all of the records from the database. The user might then be able to click a record which will show a new page in the portlet containing a form for updating the record. Adding a record would work in much the same way. Nothing shocking here...

Where do I control how the user navigates between the different views, and where do I switch between the different actions that the user might perform (update, add, delete, etc)?

I've looked online and have found a ton of "hello world" portlet tutorials, which don't help much. I've found many other tutorials that are more advanced and geared towards what I'm doing, but they all seem to use some underlying framework like Struts, JSF, etc.

I'd like to know how to make this work using just a basic portlet using JSPs to render the views.

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

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

发布评论

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

评论(1

小红帽 2024-07-23 04:36:14

Portlet API (JSR-168) 是什么你需要寻找。 这将向您解释 Portlet 容器如何管理视图、如何呈现 Portlet 以及如何映射操作。

Co

  • portlet 交互始终是两阶段 - 操作和呈现 - 而 Web 服务器交互始终是单阶段;
  • 在标准 Web 应用程序中,表单被提交到 html 表单标记的操作字段中指定的 servlet。 在 JSR-168 portlet 中,HTML 表单的操作 URL 是使用 actionURL portlet 标记生成的,例如
  • 提交 HTML 表单会导致调用 portlet servlet 的 processAction(ActionRequest aRequest, ActionResponse aResponse) 方法,
  • 允许 Servlet 执行包含、转发操作,并重定向; portlet 只允许包含。
  • Servlet 可以呈现完整的页面,而 Portlet 只能呈现页面片段。
  • 等等

Portlet API (JSR-168) is what you need to look for. This will explain to you how views are managed by portlet container, how portlets are rendered and how actions are mapped.

Co

  • portlet interaction is always 2-phase - action and render - while web server interaction is always single phase;
  • in a standard Web application, the form is submitted to the servlet specified in action field of the html form tag. In JSR-168 portlet, the action URL for an HTML form is generated using the actionURL portlet tag e.g. <form action="<portlet:actionURL/>" method="post">
  • submitting the HTML form results in invoking the processAction(ActionRequest aRequest, ActionResponse aResponse) method of a portlet
  • servlets are allowed to do include, forward, and redirect; portlets are only allowed to include.
  • Servlets can render a complete page, portlets render only page fragments.
  • and so on
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文