Author: sohil.shah(a)jboss.com
Date: 2007-07-10 16:55:32 -0400 (Tue, 10 Jul 2007)
New Revision: 7707
Added:
trunk/thirdparty/apache-ant/
trunk/thirdparty/apache-ant/component-info.xml
trunk/thirdparty/apache-ant/lib/
trunk/thirdparty/apache-ant/lib/ant.jar
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminConstants.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/create.jsp
trunk/thirdparty/
trunk/tools/etc/buildfragments/modules.ent
Log:
CMS Administration: Create File: Validate title has content - JBPORTAL-1544
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminConstants.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminConstants.java 2007-07-10
17:29:07 UTC (rev 7706)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminConstants.java 2007-07-10
20:55:32 UTC (rev 7707)
@@ -105,4 +105,6 @@
public static final String OP_VIEWPENDING = "view_pending_items";
public static final String OP_VIEWSEARCHRESULTS = "view_search_results";
+
+ public static final String OP_CREATEFILE_VALIDATION_ERROR =
"create_file_validation_error";
}
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-07-10
17:29:07 UTC (rev 7706)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-07-10
20:55:32 UTC (rev 7707)
@@ -391,7 +391,7 @@
javax.portlet.PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH +
"/editbinary.jsp");
prd.include(rReq, rRes);
}
- else if (CMSAdminConstants.OP_CREATENEWTEXT.equals(op))
+ else if (CMSAdminConstants.OP_CREATENEWTEXT.equals(op) ||
CMSAdminConstants.OP_CREATEFILE_VALIDATION_ERROR.equals(op))
{
String sPath = rReq.getParameter("path");
@@ -422,9 +422,28 @@
rRes.setContentType("text/html");
rReq.setAttribute("currpath", sPath);
rReq.setAttribute("document_base_url", sbUrl.toString() +
this.buildURL(rReq, "/"));
+
+ //If a validation error occurred, re-populate data already submitted
+ if(rReq.getParameter("error:content") != null)
+ {
+ rReq.setAttribute("error:content",
rReq.getParameter("error:content"));
+ }
+ if(rReq.getParameter("error:description") != null)
+ {
+ rReq.setAttribute("error:description",
rReq.getParameter("error:description"));
+ }
+ if(rReq.getParameter("error:title") != null)
+ {
+ rReq.setAttribute("error:title",
rReq.getParameter("error:title"));
+ }
+ if(rReq.getParameter("error:language") != null)
+ {
+ rReq.setAttribute("error:language",
rReq.getParameter("error:language"));
+ }
+
javax.portlet.PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH +
"/create.jsp");
prd.include(rReq, rRes);
- }
+ }
else if (CMSAdminConstants.OP_EDIT.equals(op))
{
String sPath = rReq.getParameter("path");
@@ -984,6 +1003,27 @@
String sTitle = aReq.getParameter("title");
String sDescription = aReq.getParameter("description");
String sLanguage = aReq.getParameter("language");
+
+ //Perform server side data validation
+ if(sFileName == null || sFileName.trim().length() == 0)
+ {
+ //Validation Error occurred
+ //FileName should not be empty
+ aRes.setRenderParameter("op",
CMSAdminConstants.OP_CREATEFILE_VALIDATION_ERROR);
+
+ //set render parameters here
+ aRes.setRenderParameter("path", sDirectory);
+
+ //used to remember the data already submitted by the user
+ aRes.setRenderParameter("error:content",
aReq.getParameter("elm1"));
+ aRes.setRenderParameter("error:description",
aReq.getParameter("description"));
+ aRes.setRenderParameter("error:title",
aReq.getParameter("title"));
+ aRes.setRenderParameter("error:language",
aReq.getParameter("language"));
+
+ return;
+ }
+
+
if (!"".equals(sFileName) &&
!"".equals(sDirectory))
{
String sContent = aReq.getParameter("elm1");
@@ -1026,7 +1066,7 @@
CMSService.execute(newFileCMD);
}
aRes.setRenderParameter("path", sNewFilePath);
- }
+ }
aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
}
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/create.jsp
===================================================================
---
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/create.jsp 2007-07-10
17:29:07 UTC (rev 7706)
+++
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/create.jsp 2007-07-10
20:55:32 UTC (rev 7707)
@@ -13,6 +13,28 @@
String[] langs = Locale.getISOLanguages();
String sDocBase = (String)request.getAttribute("document_base_url");
String sCSSURL = (String)request.getAttribute("css_url");
+
+ //validation handling related data
+ String sContent = (String)request.getAttribute("error:content");
+ String description = (String)request.getAttribute("error:description");
+ String title = (String)request.getAttribute("error:title");
+ String language = (String)request.getAttribute("error:language");
+ if(sContent == null)
+ {
+ sContent = "";
+ }
+ if(description == null)
+ {
+ description = "";
+ }
+ if(title == null)
+ {
+ title = "";
+ }
+ if(language == null)
+ {
+ language = "";
+ }
%>
<!-- tinyMCE -->
@@ -53,6 +75,21 @@
</script>
<!-- /tinyMCE -->
+<!-- data validation -->
+<script language="javascript" type="text/javascript">
+ function validateAndSubmit()
+ {
+ if(document.pickform.filename.value.length == 0)
+ {
+ alert("${n:i18n("CMS_FILENAME")} is required.");
+ }
+ else
+ {
+ document.pickform.submit();
+ }
+ }
+</script>
+
<form name="pickform" method="post"
action="<portlet:actionURL>
<portlet:param name="op" value="<%=
CMSAdminConstants.OP_SAVENEWTEXT %>"/>
<portlet:param name="path" value=""/>
@@ -75,15 +112,17 @@
</tr>
<tr>
<td>${n:i18n("CMS_FILENAME")}:</td>
- <td><input
+ <td>
+ <input
type="text" name="filename"
- class="portlet-form-input-field">
+ class="portlet-form-input-field"/>
+ : Required
</td>
</tr>
<tr>
<td>${n:i18n("CMS_DESCRIPTION")}:</td>
<td><input type="text" size="40"
maxlength="80"
- name="description" value=""
+ name="description"
value="<%=description%>"
class="portlet-form-input-field"/></td>
</tr>
<tr>
@@ -91,8 +130,9 @@
${n:i18n("CMS_TITLE")}:
</td>
<td><input type="text" size="40"
maxlength="80"
- name="title" value=""
- class="portlet-form-input-field"/></td>
+ name="title" value="<%=title%>"
+ class="portlet-form-input-field"/>
+ </td>
</tr>
<tr>
<td>
@@ -100,18 +140,26 @@
</td>
<td><select name="language"
class="portlet-form-input-field">
- <option selected
- value="<%= Locale.getDefault().getLanguage()
%>"><%= Locale.getDefault().getDisplayLanguage() %>
- </option>
+
+ <%if(language.equals("")){%>
<%
for (int i = 0; i < langs.length; i++)
{
%>
- <option value="<%= langs[i] %>"><%= new
Locale(langs[i]).getDisplayLanguage() %>
- </option>
+ <option value="<%= langs[i] %>"
<%if(langs[i].equals(Locale.getDefault().getLanguage())){%>selected<%}%>><%=
new Locale(langs[i]).getDisplayLanguage() %></option>
<%
}
%>
+ <%}else{%>
+ <%
+ for (int i = 0; i < langs.length; i++)
+ {
+ %>
+ <option value="<%= langs[i] %>"
<%if(langs[i].equals(language)){%>selected<%}%>><%= new
Locale(langs[i]).getDisplayLanguage() %></option>
+ <%
+ }
+ %>
+ <%}%>
</select>
</td>
</tr>
@@ -144,9 +192,9 @@
</tr>
<tr>
<td align="center">
- <textarea id="elm1" name="elm1" rows="20"
cols="80" style="width: 100%"></textarea>
+ <textarea id="elm1" name="elm1" rows="20"
cols="80" style="width: 100%"><%= sContent
%></textarea>
<br>
- <input type="submit" name="save"
value="${n:i18n("CMS_CREATE")}"
class="portlet-form-button"/>
+ <input type="button" name="save"
value="${n:i18n("CMS_CREATE")}" class="portlet-form-button"
onclick="javascript:validateAndSubmit();"/>
<input type="reset" name="reset" value="Reset"
class="portlet-form-button"/>
</td>
</tr>
Property changes on: trunk/thirdparty
___________________________________________________________________
Name: svn:ignore
+ antlr
*.ent
Added: trunk/thirdparty/apache-ant/component-info.xml
===================================================================
--- trunk/thirdparty/apache-ant/component-info.xml (rev 0)
+++ trunk/thirdparty/apache-ant/component-info.xml 2007-07-10 20:55:32 UTC (rev 7707)
@@ -0,0 +1,19 @@
+<project name="apache-ant-component-info">
+
+ <component id="apache-ant"
+ licenseType="apache-2.0"
+ version="1.6.5"
+
projectHome="http://ant.apache.org/"
+ description="Ant is a Java-based build tool"
+ >
+
+ <artifact id="ant.jar"/>
+ <artifact id="ant-launcher.jar"/>
+ <export>
+ <include input="ant.jar"/>
+ <include input="ant-launcher.jar"/>
+ </export>
+ </component>
+
+
+</project>
Added: trunk/thirdparty/apache-ant/lib/ant.jar
===================================================================
(Binary files differ)
Property changes on: trunk/thirdparty/apache-ant/lib/ant.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/tools/etc/buildfragments/modules.ent
===================================================================
--- trunk/tools/etc/buildfragments/modules.ent 2007-07-10 17:29:07 UTC (rev 7706)
+++ trunk/tools/etc/buildfragments/modules.ent 2007-07-10 20:55:32 UTC (rev 7707)
@@ -186,6 +186,13 @@
<pathelement
path="${jboss.portal-workflow.lib}/portal-workflow-lib.jar"/>
</path>
+ <!-- uiserver -->
+ <property name="jboss.portal-uiserver.root"
value="${project.root}/uiserver/output"/>
+ <property name="jboss.portal-uiserver.lib"
value="${jboss.portal-uiserver.root}/lib"/>
+ <path id="jboss.portal-uiserver.classpath">
+ <pathelement
path="${jboss.portal-uiserver.lib}/portal-uiserver-lib.jar"/>
+ </path>
+
<!-- samples -->
<property name="jboss.portal-samples.root"
value="${project.root}/samples/output"/>
<property name="jboss.portal-samples.lib"
value="${jboss.portal-samples.root}/lib"/>