WebScript servlet now correctly sets no-cache headers on the reponse. Improvements to MySpaces portlet.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5752 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-05-22 15:41:45 +00:00
parent 582188c7dd
commit 6388d2895a
5 changed files with 86 additions and 29 deletions

View File

@@ -48,19 +48,31 @@
</#if> </#if>
</#list> </#list>
</div> </div>
<#-- Refresh action -->
<span style="float:right;margin:6px 6px 0 0;"><a href="${scripturl("?f=${filter}&p=${path}")}" class="refreshViewLink"><img src="${url.context}/images/icons/reset.gif" border="0" width="16" height="16" style="vertical-align:-25%;padding-right:4px">Refresh</a></span> <span style="float:right;margin:6px 6px 0 0;"><a href="${scripturl("?f=${filter}&p=${path}")}" class="refreshViewLink"><img src="${url.context}/images/icons/reset.gif" border="0" width="16" height="16" style="vertical-align:-25%;padding-right:4px">Refresh</a></span>
<div class="spaceTitle"> <div class="spaceTitle">
<img src="${url.context}${home.icon16}" width="16" height="16" alt="" style="vertical-align:-25%;padding-right:4px">${home.name?html} <img src="${url.context}${home.icon16}" width="16" height="16" alt="" style="vertical-align:-25%;padding-right:4px">${home.name?html}
</div> </div>
<div class="spaceActions"> <div class="spaceActions">
<#-- TODO: haspermission check! --> <#-- TODO: permission checks on the actions! -->
<#-- Upload File action -->
<div class="spaceAction spaceActionUpload" title="Upload a new document" onclick="MySpaces.upload(this);">Upload</div> <div class="spaceAction spaceActionUpload" title="Upload a new document" onclick="MySpaces.upload(this);">Upload</div>
<div class="spaceUploadPanel"> <div class="spaceUploadPanel">
<#-- Url encode the path value, and encode any single quotes to generate valid string --> <#-- Url encode the path value, and encode any single quotes to generate valid string -->
<input style="margin:4px" type="submit" value="OK" onclick='MySpaces.uploadOK(this, "${path?url?replace("'","_%_")}");'> <input style="margin:4px" type="submit" value="OK" onclick='MySpaces.uploadOK(this, "${path?url?replace("'","_%_")}");'>
<input style="margin:4px" type="button" value="Cancel" onclick="MySpaces.uploadClose(this);"> <input style="margin:4px" type="button" value="Cancel" onclick="MySpaces.closePanel(this);">
</div>
<#-- Create Space action -->
<div class="spaceAction spaceActionCreateSpace" title="Create a new Space" onclick="MySpaces.createSpace(this);">Create Space</div>
<div class="spaceCreateSpacePanel">
<table cellspacing="2" cellpadding="2" border="0">
<tr><td>Name:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-name"></td></tr>
<tr><td>Title:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-title"></td></tr>
<tr><td>Description:</td><td><input style="margin:4px" type="text" value="" size="32" name="space-description"></td></tr>
</table>
<input style="margin:4px" type="button" value="OK" onclick='MySpaces.createSpaceOK(this, "${path?url?replace("'","_%_")}");'>
<input style="margin:4px" type="button" value="Cancel" onclick="MySpaces.closePanel(this);">
</div> </div>
<div class="spaceAction spaceActionCreateSpace" title="Create a new Space">Create Space</div>
</div> </div>
<div style="text-align: center;"> <div style="text-align: center;">
<center> <center>
@@ -75,12 +87,12 @@
</center> </center>
</div> </div>
<div id="spacePanel"> <div id="spacePanel">
<#-- populated via an AJAX call myspacecontent webscript --> <#-- populated via an AJAX call to 'myspacespanel' webscript -->
<#-- resolved path, filter and home.noderef required as arguments! --> <#-- resolved path, filter and home.noderef required as arguments -->
<script>MySpaces.Path="${path?replace("\"","\\\"")}";MySpaces.Filter="${filter}";MySpaces.Home="${home.nodeRef}";</script> <script>MySpaces.Path="${path?replace("\"","\\\"")}";MySpaces.Filter="${filter}";MySpaces.Home="${home.nodeRef}";</script>
</div> </div>
<div class="spaceFooter"> <div class="spaceFooter">
<#-- TODO: get the count value dynamically from the AJAX webscript output above... --> <#-- the count value is retrieved and set dynamically from the AJAX webscript output above -->
Showing <span id="spaceCount">0</span> items(s) Showing <span id="spaceCount">0</span> items(s)
</div> </div>
</div> </div>
@@ -271,6 +283,20 @@ a.spaceBreadcrumbLink:link, a.spaceBreadcrumbLink:visited, a.spaceBreadcrumbLink
-moz-border-radius: 5px; -moz-border-radius: 5px;
} }
.spaceCreateSpacePanel
{
position: absolute;
border: 1px solid #CCD4DB;
background-color: #EEF7FB;
width: 24em;
height: 11em;
padding: 8px;
margin: 8px;
display: none;
left: 8px;
-moz-border-radius: 5px;
}
a.refreshViewLink:link, a.refreshViewLink:visited, a.refreshViewLink:hover a.refreshViewLink:link, a.refreshViewLink:visited, a.refreshViewLink:hover
{ {
font-family: Trebuchet MS, Arial, Helvetica, sans-serif; font-family: Trebuchet MS, Arial, Helvetica, sans-serif;

View File

@@ -1,10 +1,11 @@
<#assign user=person.properties.userName> <#assign user=person.properties.userName>
<#assign count=0> <#assign count=0>
<#list companyhome.nodeByReference[args.h].childAssocs["cm:contains"]?sort_by('name') as d> <#list companyhome.nodeByReference[args.h].children?sort_by('name') as d>
<#if (args.f="0") || <#if (d.isContainer || d.isDocument) &&
(args.f="1" && d.isContainer) || ((args.f="0") ||
(args.f="2" && d.isDocument) || (args.f="1" && d.isContainer) ||
(args.f="3" && (d.properties.creator == user || d.properties.modifier == user))> (args.f="2" && d.isDocument) ||
(args.f="3" && (d.properties.creator == user || d.properties.modifier == user)))>
<#assign count=count+1> <#assign count=count+1>
<div class="spaceRow"> <div class="spaceRow">
<div class="spaceIcon"> <div class="spaceIcon">

View File

@@ -62,6 +62,9 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
/** /**
* Bean managing the ajax servlet upload of a multi-part form containing file content
* to be added at a specific path in the server.
*
* @author Kevin Roast * @author Kevin Roast
*/ */
public class FileUploadBean public class FileUploadBean
@@ -69,11 +72,11 @@ public class FileUploadBean
private static Log logger = LogFactory.getLog(FileUploadBean.class); private static Log logger = LogFactory.getLog(FileUploadBean.class);
/** /**
* Ajax method to upload a file. A multi-part form is required as the input. * Ajax method to upload file content. A multi-part form is required as the input.
* *
* "return-page" = * "return-page" = javascript to execute on return from the upload request
* "currentPath" = * "currentPath" = the cm:name based server path to upload the content into
* and the file item itself * and the file item content.
* *
* @throws Exception * @throws Exception
*/ */

View File

@@ -90,7 +90,10 @@ public class WebScriptServlet extends HttpServlet
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : ""));
res.setHeader("Cache-Control", "no-cache");
res.setHeader("Pragma", "no-cache");
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionService, authenticator, req, res); WebScriptRuntime runtime = new WebScriptServletRuntime(registry, transactionService, authenticator, req, res);
runtime.executeScript(); runtime.executeScript();
} }

View File

@@ -17,8 +17,8 @@ var MySpaces = {
// is responsible for rendering just the contents of the main panel div // is responsible for rendering just the contents of the main panel div
YAHOO.util.Connect.asyncRequest( YAHOO.util.Connect.asyncRequest(
"GET", "GET",
getContextPath() + '/service/myspacespanel?p='+MySpaces.Path+'&f='+MySpaces.Filter+'&h='+MySpaces.Home, getContextPath() + '/service/myspacespanel?p='+MySpaces.Path+'&f='+MySpaces.Filter+'&h='+MySpaces.Home, //+'&_='+(Math.random())
{ {
success: function(response) success: function(response)
{ {
// push the response into the space panel div // push the response into the space panel div
@@ -239,6 +239,39 @@ var MySpaces = {
}); });
}, },
/**
* Display the Create Space pop-up panel
*/
createSpace: function(actionEl)
{
var panel = $E(".spaceCreateSpacePanel", $(actionEl).getParent());
panel.setStyle("opacity", 0);
panel.setStyle("display", "inline");
var anim = new Fx.Styles(panel, {duration: MySpaces.ANIM_LENGTH, transition: Fx.Transitions.linear});
anim.start({'opacity': 1});
},
/**
* OK button click handler for the Create Space pop-up panel
*/
createSpaceOK: function(actionEl, path)
{
// TODO: ajax call to create space...
//path = path.replace("_%_", "'");
},
/**
* Cancel button click handler for various pop-up panels
*/
closePanel: function(actionEl)
{
var panel = $(actionEl).getParent();
panel.setStyle("display", "none");
},
/**
* Display the Upload File pop-up panel
*/
upload: function(actionEl) upload: function(actionEl)
{ {
var panel = $E(".spaceUploadPanel", $(actionEl).getParent()); var panel = $E(".spaceUploadPanel", $(actionEl).getParent());
@@ -272,22 +305,13 @@ var MySpaces = {
{ {
// call the upload help to perform the upload // call the upload help to perform the upload
handleUploadHelper(this.fileInput, handleUploadHelper(this.fileInput,
"1", // TODO: generate unique ID (parent space noderef?) "1", // TODO: generate unique ID? (parent space noderef?)
MySpaces.uploadCompleteHandler, MySpaces.uploadCompleteHandler,
getContextPath(), getContextPath(),
"/ajax/invoke/FileUploadBean.uploadFile", "/ajax/invoke/FileUploadBean.uploadFile",
{currentPath: path.replace("_%_", "'")}); // decode path {currentPath: path.replace("_%_", "'")}); // decode path
this.fileInput = null; this.fileInput = null;
this.uploadClose(actionEl); this.closePanel(actionEl);
},
/**
* Cancel button click handler for the Upload File pop-up panel
*/
uploadClose: function(actionEl)
{
var panel = $(actionEl).getParent();
panel.setStyle("display", "none");
}, },
/** /**