Source code for: /alkacon-documentation/examples_directedit/demo_6.jsp
<%@ page import="java.util.*, org.opencms.file.*, org.opencms.jsp.*"
buffer="none"
session="false"
%><%
// create a JSP action element
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
// create nav builder
CmsJspNavBuilder nav = cms.getNavigation();
List entries = nav.getNavigationForFolder();
// get own uri
String uri = cms.getRequestContext().getUri();
// get the template
String template = cms.property("template", uri);
// get edit uri
String editUri = request.getParameter("edit");
// include the template head
cms.include(template, "head");
// set editable
cms.editable(true);
%>
<h2>Demo for the Java API on a JSP</h2>
<P>
Please see the source code of the JSP generating this page for an example
of how to work with including an editable "body" element from selectable pages.
</P>
<!-- Selector for body element -->
<p style="white-space: nowrap;">
<form action="" style="margin: 0px; padding: 0px;">
Please select the page whose body element should be shown:
<select name="selector" onChange="location.href='<%= cms.link(uri) %>?edit='+this.form.selector.options[this.form.selector.options.selectedIndex].text">
<% for (Iterator i = entries.iterator(); i.hasNext();) {
String u = ((CmsJspNavElement)i.next()).getFileName();
if (!u.startsWith("index") && u.endsWith("html")) {
if (editUri == null) {
editUri = u;
}
%>
<option <%= (u.equals(editUri)?"selected=\"selected\"":"") %>><%= u %></option>
<% }
}
%>
</select>
</form>
</p>
<p>
<!-- Editable body element -->
<%
// include editable element from another file
cms.include(editUri, "body", true);
%>
<!-- /Editable body element -->
</p>
<%
// include the template foot
cms.include(template, "foot");
%>
|