Author: agilliland
Date: Fri May 18 16:38:32 2007
New Revision: 539633
URL: http://svn.apache.org/viewvc?view=rev&rev=539633
Log:
cleanup some broken pieces of the template editing actions.
Modified:
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateAdd.java
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEdit.java
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEditBean.java
roller/trunk/web/WEB-INF/classes/struts.xml
roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp
roller/trunk/web/WEB-INF/jsps/authoring/struts2/Templates.jsp
roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp
roller/trunk/web/WEB-INF/tiles.xml
Modified:
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateAdd.java
URL:
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateAdd.java?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateAdd.java
(original)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateAdd.java
Fri May 18 16:38:32 2007
@@ -95,6 +95,10 @@
// flush results to db
RollerFactory.getRoller().flush();
+ // reset form fields
+ setNewTmplName(null);
+ setNewTmplAction(null);
+
} catch (RollerException ex) {
log.error("Error adding new template for weblog -
"+getActionWeblog().getHandle(), ex);
// TODO: i18n
Modified:
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEdit.java
URL:
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEdit.java?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEdit.java
(original)
+++ roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEdit.java
Fri May 18 16:38:32 2007
@@ -44,11 +44,14 @@
*/
public class TemplateEdit extends UIAction {
- private static Log log = LogFactory.getLog(Templates.class);
+ private static Log log = LogFactory.getLog(TemplateEdit.class);
// form bean for collection all template properties
private TemplateEditBean bean = new TemplateEditBean();
+ // the template we are working on
+ private WeblogTemplate template = null;
+
public TemplateEdit() {
this.actionName = "template";
@@ -57,57 +60,67 @@
}
- // must be a weblog admin to use this action
+ @Override
public short requiredWeblogPermissions() {
return PermissionsData.ADMIN;
}
- public String execute() {
-
+ public void myPrepare() {
try {
UserManager mgr = RollerFactory.getRoller().getUserManager();
- WeblogTemplate page = mgr.getPage(getBean().getId());
- if(page == null) {
- throw new RollerException("page not found");
- }
-
- getBean().copyFrom(page);
-
- // empty content-type indicates that page uses auto content-type
detection
- if (StringUtils.isEmpty(page.getOutputContentType())) {
- getBean().setAutoContentType(Boolean.TRUE);
- } else {
- getBean().setAutoContentType(Boolean.FALSE);
- getBean().setManualContentType(page.getOutputContentType());
- }
-
+ setTemplate(mgr.getPage(getBean().getId()));
} catch (RollerException ex) {
- log.error("Error loading page to edit - "+getBean().getId(), ex);
+ log.error("Error looking up template - "+getBean().getId(), ex);
+ }
+ }
+
+
+ /**
+ * Show template edit page.
+ */
+ public String execute() {
+
+ if(getTemplate() == null) {
// TODO: i18n
- addError("Couldn't find specified page to edit");
- return "list";
+ addError("Unable to locate specified template");
+ return LIST;
+ }
+
+ WeblogTemplate page = getTemplate();
+ getBean().copyFrom(template);
+
+ // empty content-type indicates that page uses auto content-type
detection
+ if (StringUtils.isEmpty(page.getOutputContentType())) {
+ getBean().setAutoContentType(Boolean.TRUE);
+ } else {
+ getBean().setAutoContentType(Boolean.FALSE);
+ getBean().setManualContentType(page.getOutputContentType());
}
return SUCCESS;
}
+ /**
+ * Save an existing template.
+ */
public String save() {
+ if(getTemplate() == null) {
+ // TODO: i18n
+ addError("Unable to locate specified template");
+ return LIST;
+ }
+
// validation
myValidate();
if(!hasActionErrors()) try {
- UserManager mgr = RollerFactory.getRoller().getUserManager();
- WeblogTemplate page = mgr.getPage(getBean().getId());
- if(page == null) {
- throw new RollerException("page not found");
- }
-
+ WeblogTemplate page = getTemplate();
getBean().copyTo(page);
- page.setLastModified( new Date() );
+ page.setLastModified(new Date());
if (getBean().getAutoContentType() == null ||
!getBean().getAutoContentType().booleanValue()) {
@@ -118,9 +131,11 @@
}
// save template and flush
- mgr.savePage( page );
+ UserManager mgr = RollerFactory.getRoller().getUserManager();
+ mgr.savePage(page);
RollerFactory.getRoller().flush();
+ // notify caches
CacheManager.invalidate(page);
// success message
@@ -170,6 +185,14 @@
public void setBean(TemplateEditBean bean) {
this.bean = bean;
+ }
+
+ public WeblogTemplate getTemplate() {
+ return template;
+ }
+
+ public void setTemplate(WeblogTemplate template) {
+ this.template = template;
}
}
Modified:
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEditBean.java
URL:
http://svn.apache.org/viewvc/roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEditBean.java?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
---
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEditBean.java
(original)
+++
roller/trunk/src/org/apache/roller/ui/authoring/struts2/TemplateEditBean.java
Fri May 18 16:38:32 2007
@@ -1,10 +1,19 @@
/*
- * TemplateEditBean.java
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Created on April 23, 2007, 3:24 PM
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
package org.apache.roller.ui.authoring.struts2;
@@ -25,15 +34,13 @@
private String description;
private String link;
private String contents;
- private java.util.Date lastModified;
private String templateLanguage;
private boolean navbar;
private boolean hidden;
- private String decoratorName;
private String outputContentType;
+
private Boolean autoContentType = Boolean.TRUE;
private String manualContentType = null;
- private boolean required = false;
public String getId() {
@@ -84,14 +91,6 @@
this.contents = contents;
}
- public java.util.Date getLastModified() {
- return this.lastModified;
- }
-
- public void setLastModified( java.util.Date lastModified ) {
- this.lastModified = lastModified;
- }
-
public String getTemplateLanguage() {
return this.templateLanguage;
}
@@ -116,14 +115,6 @@
this.hidden = hidden;
}
- public String getDecoratorName() {
- return this.decoratorName;
- }
-
- public void setDecoratorName( String decoratorName ) {
- this.decoratorName = decoratorName;
- }
-
public String getOutputContentType() {
return this.outputContentType;
}
@@ -148,18 +139,7 @@
this.manualContentType = manualContentType;
}
- public boolean isRequired() {
- return required;
- }
-
- public void setRequired(boolean required) {
- this.required = required;
- }
-
- /**
- * Copy values from this form bean to the specified data object.
- */
public void copyTo(WeblogTemplate dataHolder) {
// only custom templates get to modify name, description, and link
@@ -170,19 +150,13 @@
}
dataHolder.setContents(this.contents);
- dataHolder.setLastModified(this.lastModified);
dataHolder.setTemplateLanguage(this.templateLanguage);
dataHolder.setNavbar(this.navbar);
dataHolder.setHidden(this.hidden);
- dataHolder.setDecoratorName(this.decoratorName);
dataHolder.setOutputContentType(this.outputContentType);
}
- /**
- * Copy values from specified data object to this form bean.
- * Includes all types.
- */
public void copyFrom(WeblogTemplate dataHolder) {
this.id = dataHolder.getId();
@@ -191,13 +165,10 @@
this.description = dataHolder.getDescription();
this.link = dataHolder.getLink();
this.contents = dataHolder.getContents();
- this.lastModified = dataHolder.getLastModified();
this.templateLanguage = dataHolder.getTemplateLanguage();
this.navbar = dataHolder.isNavbar();
this.hidden = dataHolder.isHidden();
- this.decoratorName = dataHolder.getDecoratorName();
this.outputContentType = dataHolder.getOutputContentType();
- this.required = dataHolder.isRequired();
}
}
Modified: roller/trunk/web/WEB-INF/classes/struts.xml
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/classes/struts.xml?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/web/WEB-INF/classes/struts.xml (original)
+++ roller/trunk/web/WEB-INF/classes/struts.xml Fri May 18 16:38:32 2007
@@ -333,17 +333,22 @@
<result name="list" type="tiles">.Templates</result>
</action>
- <action name="templateRemove!*" method="{1}"
- class="org.apache.roller.ui.authoring.struts2.TemplateRemove">
- <result name="confirm" type="tiles">.TemplateRemove</result>
+ <action name="templateAdd!*" method="{1}"
+ class="org.apache.roller.ui.authoring.struts2.TemplateAdd">
<result name="success" type="chain">templates</result>
</action>
- <action name="template!*" method="{1}"
+ <action name="templateEdit!*" method="{1}"
class="org.apache.roller.ui.authoring.struts2.TemplateEdit">
<result name="list" type="chain">templates</result>
- <result name="success" type="tiles">.TemplateEditForm</result>
+ <result name="success" type="tiles">.TemplateEdit</result>
<result name="cancel" type="redirect-action">templates</result>
+ </action>
+
+ <action name="templateRemove!*" method="{1}"
+ class="org.apache.roller.ui.authoring.struts2.TemplateRemove">
+ <result name="confirm" type="tiles">.TemplateRemove</result>
+ <result name="success" type="chain">templates</result>
</action>
<action name="members!*" method="{1}"
Modified: roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp (original)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp Fri May 18
16:38:32 2007
@@ -24,19 +24,17 @@
</s:text>
</p>
-<s:if test="bean.required">
+<s:if test="template.required">
<p class="pagetip"><s:text name="pageForm.tip.required" /></p>
</s:if>
<s:else>
<p class="pagetip"><s:text name="pageForm.tip" /></p>
</s:else>
-<s:form action="template!save" id="template">
+<s:form action="templateEdit!save" id="template">
+ <s:hidden name="weblog" />
<s:hidden name="bean.id"/>
- <s:hidden name="bean.decoratorName" />
- <s:hidden name="bean.required" />
<s:hidden name="bean.action" />
- <s:hidden name="weblog" value="%{actionWeblog.handle}" />
<%-- ==================================================================
--%>
<%-- Name, link and desription: disabled when page is a required page --%>
@@ -45,7 +43,7 @@
<tr>
<td class="label"><s:text name="pageForm.name" /> </td>
<td class="field">
- <s:if test="bean.required">
+ <s:if test="template.required">
<span class="fixedAttr"><s:property
value="bean.name"/></span>
<s:hidden name="bean.name" />
</s:if>
@@ -92,11 +90,11 @@
-->
</script>
- <s:if test="!bean.required">
+ <s:if test="!template.required">
<tr>
<td class="label" valign="top"><s:text name="pageForm.link"
/> </td>
<td class="field">
- <s:if test="bean.required">
+ <s:if test="template.required">
<span class="fixedAttr"><s:property
value="bean.link"/></span>
<s:hidden name="bean.link" />
</s:if>
@@ -115,7 +113,7 @@
<tr>
<td class="label" valign="top" style="padding-top: 4px"><s:text
name="pageForm.description" /> </td>
<td class="field">
- <s:if test="bean.required">
+ <s:if test="template.required">
<span class="fixedAttr"><s:property
value="bean.description"/></span>
<s:hidden name="bean.description" />
</s:if>
@@ -136,7 +134,7 @@
<script type="text/javascript"><!--
if (getCookie("editorSize1") != null) {
- document.weblogTemplateFormEx.contents.rows =
getCookie("editorSize1");
+ document.getElementById('template_bean_contents').rows =
getCookie("editorSize1");
}
function changeSize(e, num) {
a = e.rows + num;
@@ -162,9 +160,9 @@
<td align="right">
<!-- Add buttons to make this textarea taller or shorter -->
<input type="button" name="taller" value=" ↓ "
-
onclick="changeSize1(document.template.template_bean_contents, 5)" />
+
onclick="changeSize1(document.getElementById('template_bean_contents'), 5)" />
<input type="button" name="shorter" value=" ↑ "
-
onclick="changeSize1(document.template.template_bean_contents, -5)" />
+
onclick="changeSize1(document.getElementById('template_bean_contents'), -5)" />
</td>
</tr>
</table>
@@ -187,12 +185,12 @@
<tr>
<script type="text/javascript"><!--
function showContentTypeField() {
- if
(document.weblogTemplateFormEx.autoContentType[0].checked) {
-
document.weblogTemplateFormEx.manualContentType.readOnly = true;
-
document.weblogTemplateFormEx.manualContentType.style.background = '#e5e5e5';
+ if
(document.getElementById('template_bean_autoContentType1').checked) {
+
document.getElementById('template_bean_manualContentType').readOnly = true;
+
document.getElementById('template_bean_manualContentType').style.background =
'#e5e5e5';
} else {
-
document.weblogTemplateFormEx.manualContentType.readOnly = false;
-
document.weblogTemplateFormEx.manualContentType.style.background = '#ffffff';
+
document.getElementById('template_bean_manualContentType').readOnly = false;
+
document.getElementById('template_bean_manualContentType').style.background =
'#ffffff';
}
}
// --></script>
@@ -200,13 +198,22 @@
<tr>
<td class="label" valign="top"><s:text
name="pageForm.outputContentType" /> </td>
<td class="field">
-
- <s:radio name="autoContentType" list="{true}"
onchange="showContentTypeField()" />
- <s:text name="pageForm.useAutoContentType" /><br />
-
- <s:radio name="autoContentType" list="{false}"
onchange="showContentTypeField()" />
- <s:text name="pageForm.useManualContentType" />
- <s:textfield name="manualContentType" />
+ <s:if test="bean.autoContentType">
+ <input type="radio"
name="bean.autoContentType" value="true" checked="true"
onchange="showContentTypeField()" id="template_bean_autoContentType1"/>
+ <s:text name="pageForm.useAutoContentType"
/><br />
+
+ <input type="radio"
name="bean.autoContentType" value="false" onchange="showContentTypeField()"
id="template_bean_autoContentType2"/>
+ <s:text name="pageForm.useManualContentType" />
+ <s:textfield name="bean.manualContentType" />
+ </s:if>
+ <s:else>
+ <input type="radio"
name="bean.autoContentType" value="true" onchange="showContentTypeField()"
id="template_bean_autoContentType1"/>
+ <s:text name="pageForm.useAutoContentType"
/><br />
+
+ <input type="radio"
name="bean.autoContentType" value="false" checked="true"
onchange="showContentTypeField()" id="template_bean_autoContentType2"/>
+ <s:text name="pageForm.useManualContentType" />
+ <s:textfield name="bean.manualContentType" />
+ </s:else>
<br />
<br />
@@ -223,13 +230,13 @@
<tr>
<td class="field">
- <s:if test="bean.required">
- <s:hidden name="navbar" />
+ <s:if test="template.required">
+ <s:hidden name="bean.navbar" />
</s:if>
<s:else>
<tr>
<td class="label"><s:text name="pageForm.navbar"
/> </td>
- <td class="field"><s:checkbox name="navbar" />
+ <td class="field"><s:checkbox name="bean.navbar"
/>
<s:text name="pageForm.navbar.tip" />
</td>
<td class="description"></td>
@@ -240,13 +247,13 @@
</tr>
<td class="field">
- <s:if test="bean.required">
- <s:hidden name="hidden" />
+ <s:if test="template.required">
+ <s:hidden name="bean.hidden" />
</s:if>
<s:else>
<tr>
<td class="label"><s:text name="pageForm.hidden"
/> </td>
- <td class="field"><s:checkbox name="hidden" />
+ <td class="field"><s:checkbox name="bean.hidden" />
<s:text name="pageForm.hidden.tip" />
</td>
<td class="description"></td>
@@ -261,14 +268,14 @@
<tr>
<td class="field">
- <s:if test="bean.required ||
!model.rollerSession.globalAdminUser}">
- <s:hidden name="templateLanguage" />
+ <s:if test="template.required || !userIsAdmin}">
+ <s:hidden name="bean.templateLanguage" />
</s:if>
<s:else>
<tr>
<td class="label"><s:text
name="pageForm.templateLanguage" /> </td>
<td class="field">
- <s:select name="templateLanguage"
list="templateLanguages" size="1" />
+ <s:select name="bean.templateLanguage"
list="templateLanguages" size="1" />
</td>
<td class="description"></td>
</tr>
@@ -284,13 +291,3 @@
<br />
</s:form>
-
-<%--
-Added by Matt Raible since the focus javascript generated by Struts
-doesn't seem to work for forms with duplicate named elements.
---%>
-<script type="text/javascript">
-<!--
- document.forms[0].elements[0].focus();
-// -->
-</script>
Modified: roller/trunk/web/WEB-INF/jsps/authoring/struts2/Templates.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/Templates.jsp?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/Templates.jsp (original)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/Templates.jsp Fri May 18
16:38:32 2007
@@ -53,7 +53,7 @@
<s:url id="editIcon" value="/images/page_white_gear.png"/>
</s:else>
<img src='<s:url value="%{editIcon}"/>' border="0" alt="icon"
/>
- <s:url id="edit" action="template">
+ <s:url id="edit" action="templateEdit">
<s:param name="weblog" value="actionWeblog.handle" />
<s:param name="bean.id" value="#p.id" />
</s:url>
Modified: roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp
(original)
+++ roller/trunk/web/WEB-INF/jsps/authoring/struts2/TemplatesSidebar.jsp Fri
May 18 16:38:32 2007
@@ -21,38 +21,38 @@
<div class="menu-tr">
<div class="menu-tl">
-<div class="sidebarInner">
- <h3><s:text name="pagesForm.addNewPage" /></h3>
- <hr size="1" noshade="noshade" />
-
- <s:form action="templateAdd!save">
- <s:hidden name="weblog" value="%{actionWeblog.handle}" />
-
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td><s:text name="pagesForm.name"/>:</td>
- <td><s:textfield name="newTmplName" /></td>
- </tr>
-
- <s:if test="!availableActions.isEmpty" >
- <tr>
- <td><s:text name="pagesForm.action"/>:</td>
- <td>
- <s:select name="newTmplAction" size="1"
list="availableActions" />
- </td>
- </tr>
- </s:if>
-
- <tr>
- <td></td>
- <td><s:submit key="pagesForm.add" /></td>
- </tr>
- </table>
-
- </s:form>
- <br />
-
-</div>
+ <div class="sidebarInner">
+ <h3><s:text name="pagesForm.addNewPage" /></h3>
+ <hr size="1" noshade="noshade" />
+
+ <s:form action="templateAdd!save">
+ <s:hidden name="weblog" />
+
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><s:text name="pagesForm.name"/>:</td>
+ <td><s:textfield name="newTmplName" /></td>
+ </tr>
+
+ <s:if test="!availableActions.isEmpty" >
+ <tr>
+ <td><s:text name="pagesForm.action"/>:</td>
+ <td>
+ <s:select name="newTmplAction" size="1"
list="availableActions" />
+ </td>
+ </tr>
+ </s:if>
+
+ <tr>
+ <td></td>
+ <td><s:submit key="pagesForm.add" /></td>
+ </tr>
+ </table>
+
+ </s:form>
+ <br />
+
+ </div>
</div>
</div>
</div>
Modified: roller/trunk/web/WEB-INF/tiles.xml
URL:
http://svn.apache.org/viewvc/roller/trunk/web/WEB-INF/tiles.xml?view=diff&rev=539633&r1=539632&r2=539633
==============================================================================
--- roller/trunk/web/WEB-INF/tiles.xml (original)
+++ roller/trunk/web/WEB-INF/tiles.xml Fri May 18 16:38:32 2007
@@ -270,6 +270,7 @@
</definition>
<definition name=".ThemeEdit" extends=".tiles-tabbedpage" >
+ <put name="head" value="/WEB-INF/jsps/tiles/struts2/head-ajax.jsp" />
<put name="content"
value="/WEB-INF/jsps/authoring/struts2/ThemeEdit.jsp" />
</definition>
@@ -279,13 +280,13 @@
<put name="styles" value="/WEB-INF/jsps/tiles/struts2/css-sidebar.jsp"
/>
</definition>
- <definition name=".TemplateRemove" extends=".tiles-tabbedpage" >
- <put name="content"
value="/WEB-INF/jsps/authoring/struts2/TemplateRemove.jsp" />
+ <definition name=".TemplateEdit" extends=".tiles-tabbedpage" >
+ <put name="content"
value="/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp" />
<put name="styles"
value="/WEB-INF/jsps/tiles/struts2/css-nosidebar.jsp" />
</definition>
- <definition name=".TemplateEditForm" extends=".tiles-tabbedpage" >
- <put name="content"
value="/WEB-INF/jsps/authoring/struts2/TemplateEdit.jsp" />
+ <definition name=".TemplateRemove" extends=".tiles-tabbedpage" >
+ <put name="content"
value="/WEB-INF/jsps/authoring/struts2/TemplateRemove.jsp" />
<put name="styles"
value="/WEB-INF/jsps/tiles/struts2/css-nosidebar.jsp" />
</definition>