Return-Path: Delivered-To: apmail-roller-commits-archive@www.apache.org Received: (qmail 44056 invoked from network); 18 May 2007 23:38:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 May 2007 23:38:55 -0000 Received: (qmail 13254 invoked by uid 500); 18 May 2007 23:39:01 -0000 Delivered-To: apmail-roller-commits-archive@roller.apache.org Received: (qmail 13221 invoked by uid 500); 18 May 2007 23:39:00 -0000 Mailing-List: contact commits-help@roller.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@roller.apache.org Delivered-To: mailing list commits@roller.apache.org Received: (qmail 13211 invoked by uid 99); 18 May 2007 23:39:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2007 16:39:00 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2007 16:38:53 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 767501A981C; Fri, 18 May 2007 16:38:33 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r539633 - in /roller/trunk: src/org/apache/roller/ui/authoring/struts2/ web/WEB-INF/ web/WEB-INF/classes/ web/WEB-INF/jsps/authoring/struts2/ Date: Fri, 18 May 2007 23:38:33 -0000 To: commits@roller.apache.org From: agilliland@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070518233833.767501A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ .Templates - - .TemplateRemove + templates - templates - .TemplateEditForm + .TemplateEdit templates + + + + .TemplateRemove + templates

- +

- + + - - - <%-- ================================================================== --%> <%-- Name, link and desription: disabled when page is a required page --%> @@ -45,7 +43,7 @@   - + @@ -92,11 +90,11 @@ --> - +   - + @@ -115,7 +113,7 @@   - + @@ -136,7 +134,7 @@ @@ -200,13 +198,22 @@   - - -
- - - - + + +
+ + + + +
+ + +
+ + + + +


@@ -223,13 +230,13 @@ - - + +   - + @@ -240,13 +247,13 @@ - - + +   - + @@ -261,14 +268,14 @@ - - + +   - + @@ -284,13 +291,3 @@
- -<%-- -Added by Matt Raible since the focus javascript generated by Struts -doesn't seem to work for forms with duplicate named elements. ---%> - 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 @@ icon - + 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 @@ 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 @@ + @@ -279,13 +280,13 @@ - - + + - - + +