Merged V3.1 to HEAD

13304: Final part of I18N fixes for Share. TinyMCE editor lang packs: fr, de, jp, es. Added Spanish (es) to web-client TinyMCE integration also which was missing it.
   13316: Liferay Portal 4.3.X fixes for JSF Client portlet:
           - Tested deployment instructions for Alfresco and Liferay 4.3.X - still work as per wiki page http://wiki.alfresco.com/wiki/Deploying_2.1WAR_Liferay4.3
           - Upload is working (tested from Add Content, Upload New Version and Update)
           - Fixed bug raised in ETHREEOH-1170
          NOTE: there are still issues with the other Ajax Mootools powered portlets...
   13333: Fix for ETHREEOH-1410, ETHREEOH-1402, ETHREEOH-1396, ETHREEOH-1393, ETHREEOH-1380, ETHREEOH-1274, ETHREEOH-1266, ETHREEOH-1257 - Paging control submit box now correctly handles enter key press without submitting parent form.
   13348: Fix for ETHREEOH-980 - a user home space can no longer be set directly to User Homes.
          So they are not accidently given full permissions to that folder or the ability to rename it later.
   13349: Fix for ETHREEOH-980 - a user home space can no longer be set directly to User Homes [missed files]
   13350: Fix for ETHREEOH-971. CIFS and WebDav online edit modes fixed to work in IE as best as possible in FF.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13590 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-03-12 11:19:13 +00:00
parent 2bc702e125
commit b906c50cdf
27 changed files with 995 additions and 123 deletions

View File

@@ -38,11 +38,9 @@ import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document online via CIFS.
*
*/
public class EditDocOnlineCIFSEvaluator extends CheckoutDocEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
@@ -57,13 +55,14 @@ public class EditDocOnlineCIFSEvaluator extends CheckoutDocEvaluator
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
Map<String, Object> props = node.getProperties();
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false || props.get(ApplicationModel.PROP_EDITINLINE) == null ||
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == false) && "cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
if ("cifs".equals(Application.getClientConfig(fc).getEditLinkType()) &&
(!node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) ||
props.get(ApplicationModel.PROP_EDITINLINE) == null ||
!((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue()))
{
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
{
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
result = true;
result = (EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE)));
}
else
{
@@ -71,8 +70,7 @@ public class EditDocOnlineCIFSEvaluator extends CheckoutDocEvaluator
}
}
}
return result;
}
}
}

View File

@@ -37,11 +37,9 @@ import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document online via http.
*
*/
public class EditDocOnlineHttpEvaluator extends CheckoutDocEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
@@ -49,10 +47,10 @@ public class EditDocOnlineHttpEvaluator extends CheckoutDocEvaluator
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
if(node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
if (node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
// this branch from EditDocHttpEvaluator
// skip, result = false
@@ -61,13 +59,12 @@ public class EditDocOnlineHttpEvaluator extends CheckoutDocEvaluator
{
Map<String, Object> props = node.getProperties();
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) &&
props.get(ApplicationModel.PROP_EDITINLINE) != null &&
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true))
props.get(ApplicationModel.PROP_EDITINLINE) != null &&
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue()))
{
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
{
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
result = true;
result = EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE));
}
else
{
@@ -75,8 +72,7 @@ public class EditDocOnlineHttpEvaluator extends CheckoutDocEvaluator
}
}
}
return result;
}
}

View File

@@ -39,11 +39,9 @@ import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document online via WebDav.
*
*/
public class EditDocOnlineWebDavEvaluator extends CheckoutDocEvaluator
{
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
@@ -51,21 +49,22 @@ public class EditDocOnlineWebDavEvaluator extends CheckoutDocEvaluator
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// if the node is inline editable, the inline online editing should always be used
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
Map<String, Object> props = node.getProperties();
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false || props.get(ApplicationModel.PROP_EDITINLINE) == null ||
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == false) && "webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
if ("webdav".equals(Application.getClientConfig(fc).getEditLinkType()) &&
(!node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) ||
props.get(ApplicationModel.PROP_EDITINLINE) == null ||
!((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue()))
{
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
{
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
result = true;
result = (EditOnlineDialog.ONLINE_EDITING.equals(props.get(ContentModel.PROP_WORKING_COPY_MODE)));
}
else
{
@@ -73,8 +72,7 @@ public class EditDocOnlineWebDavEvaluator extends CheckoutDocEvaluator
}
}
}
return result;
}
}
}

View File

@@ -25,6 +25,7 @@ package org.alfresco.web.app.servlet;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.ServletConfig;
@@ -59,7 +60,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
*/
public class UploadFileServlet extends BaseServlet
{
private static final long serialVersionUID = -5482538466491052873L;
private static final long serialVersionUID = -5482538466491052875L;
private static final Log logger = LogFactory.getLog(UploadFileServlet.class);
private ConfigService configService;
@@ -165,8 +166,30 @@ public class UploadFileServlet extends BaseServlet
}
}
session.setAttribute(FileUploadBean.getKey(uploadId), bean);
// examine the appropriate session to try and find the User object
if (Application.inPortalServer() == false)
{
session.setAttribute(FileUploadBean.getKey(uploadId), bean);
}
else
{
// naff solution as we need to enumerate all session keys until we find the one that
// should match our User objects - this is weak but we don't know how the underlying
// Portal vendor has decided to encode the objects in the session
Enumeration enumNames = session.getAttributeNames();
while (enumNames.hasMoreElements())
{
String name = (String)enumNames.nextElement();
// find an Alfresco value we know must be there...
if (name.startsWith("javax.portlet.p") && name.endsWith(AuthenticationHelper.AUTHENTICATION_USER))
{
String key = name.substring(0, name.lastIndexOf(AuthenticationHelper.AUTHENTICATION_USER));
session.setAttribute(key + FileUploadBean.getKey(uploadId), bean);
break;
}
}
}
if (bean.getFile() == null && uploadId != null && logger.isWarnEnabled())
{
logger.warn("no file uploaded for upload id: " + uploadId);

View File

@@ -40,15 +40,14 @@ import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink;
/**
* This is fiction dialog class for provides method for online editing. He
* doesn't have entry in web-client-config-dialogs.xml
*
* This base dialog class provides methods for online editing. It does
* doesn't have entry in web-client-config-dialogs.xml as is not instantiated directly.
*/
public class EditOnlineDialog extends CCCheckoutFileDialog
{
public final static String ONLINE_EDITING = "onlineEditing";
/**
* Action listener for handle webdav online editing action. E.g "edit_doc_online_webdav" action
*
@@ -57,24 +56,23 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
public void handleWebdavEditing(ActionEvent event)
{
handle(event);
Node workingCopyNode = property.getDocument();
if (workingCopyNode != null)
{
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String webdavUrl = params.get("webdavUrl");
if (webdavUrl != null)
{
// modify webDav for editing working copy
property.setWebdavUrl(webdavUrl.substring(0, webdavUrl.lastIndexOf("/") + 1) + workingCopyNode.getName());
property.setWebdavUrl(webdavUrl.substring(0, webdavUrl.lastIndexOf('/') + 1) + workingCopyNode.getName());
}
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,"dialog:close:browse");
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
}
}
@@ -86,23 +84,23 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
public void handleCifsEditing(ActionEvent event)
{
handle(event);
Node workingCopyNode = property.getDocument();
if (workingCopyNode != null)
{
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String cifsPath = params.get("cifsPath");
if (cifsPath != null)
{
// modify cifsPath for editing working copy
property.setCifsPath(cifsPath.substring(0, cifsPath.lastIndexOf("/") + 1) + workingCopyNode.getName());
property.setCifsPath(cifsPath.substring(0, cifsPath.lastIndexOf('\\') + 1) + workingCopyNode.getName());
}
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,"dialog:close:browse");
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
}
}
@@ -114,23 +112,22 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
public void handleHttpEditing(ActionEvent event)
{
handle(event);
Node workingCopyNode = property.getDocument();
if (workingCopyNode != null)
{
ContentReader reader = property.getContentService().getReader(workingCopyNode.getNodeRef(), ContentModel.PROP_CONTENT);
if (reader != null)
{
String mimetype = reader.getMimetype();
// calculate which editor screen to display
if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || MimetypeMap.MIMETYPE_XML.equals(mimetype) || MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype)
|| MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || MimetypeMap.MIMETYPE_XML.equals(mimetype) ||
MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype) || MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
{
// make content available to the text editing screen
property.setEditorOutput(reader.getContentString());
// navigate to appropriate screen
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
@@ -142,7 +139,7 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
// make content available to the html editing screen
property.setDocumentContent(reader.getContentString());
property.setEditorOutput(null);
// navigate to appropriate screen
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
@@ -150,7 +147,6 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editHtmlInline");
}
}
}
}
@@ -162,7 +158,7 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
public void handle(ActionEvent event)
{
super.setupContentAction(event);
Node node = property.getDocument();
if (node != null)
{
@@ -202,5 +198,4 @@ public class EditOnlineDialog extends CCCheckoutFileDialog
}
}
}
}
}

View File

@@ -73,7 +73,9 @@ public class CreateUserWizard extends BaseWizardBean
private static Log logger = LogFactory.getLog(BaseWizardBean.class);
protected static final String ERROR = "error_person";
protected static final String ERROR_DOMAIN_MISMATCH = "error_domain_mismatch";
private static final String MSG_ERROR_NEWUSER_HOME_SPACE = "error_newuser_home_space";
protected static final String QUOTA_UNITS_KB = "kilobyte";
protected static final String QUOTA_UNITS_MB = "megabyte";
protected static final String QUOTA_UNITS_GB = "gigabyte";
@@ -751,7 +753,7 @@ public class CreateUserWizard extends BaseWizardBean
{
// Admin Authority has full permissions by default (automatic - set in the permission config)
// give full permissions to the new user
getPermissionService().setPermission(homeSpaceRef, this.userName, getPermissionService().getAllPermission(), true);
getPermissionService().setPermission(homeSpaceRef, this.userName, getPermissionService().getAllPermission(), true);
// by default other users will only have GUEST access to the space contents
// or whatever is configured as the default in the web-client-xml config
@@ -815,8 +817,12 @@ public class CreateUserWizard extends BaseWizardBean
}
else if (this.homeSpaceLocation != null)
{
// set to existing
homeSpaceNodeRef = homeSpaceLocation;
// set to existing - first ensure it is NOT "User Homes" space!
if (this.defaultHomeSpaceRef.equals(this.homeSpaceLocation))
{
throw new AlfrescoRuntimeException(Application.getMessage(context, MSG_ERROR_NEWUSER_HOME_SPACE));
}
homeSpaceNodeRef = this.homeSpaceLocation;
setupHomeSpacePermissions(homeSpaceNodeRef);
}
else
@@ -866,7 +872,8 @@ public class CreateUserWizard extends BaseWizardBean
outcome = null;
}
if (outcome == null) {
if (outcome == null)
{
this.isFinished = false;
}
@@ -887,15 +894,15 @@ public class CreateUserWizard extends BaseWizardBean
{
if (quota != null)
{
if (quota >= 0L)
{
quota = convertToBytes(quota, quotaUnits);
}
else
{
// ignore negative quota
return;
}
if (quota >= 0L)
{
quota = convertToBytes(quota, quotaUnits);
}
else
{
// ignore negative quota
return;
}
}
getContentUsageService().setUserQuota(userName, (quota == null ? -1 : quota));

View File

@@ -269,7 +269,10 @@ public final class Utils extends StringUtils
buf.append("']['");
buf.append(name);
buf.append("'].value='");
buf.append(replace(params.get(name), "'", "\\'"));
String val = params.get(name);
val = replace(val, "\\", "\\\\"); // encode escape character
val = replace(val, "'", "\\'"); // encode single quote as we wrap string with that
buf.append(val);
buf.append("';");
// weak, but this seems to be the way Sun RI do it...
@@ -390,24 +393,25 @@ public final class Utils extends StringUtils
if (nodeService != null && navBean != null && cifsServer != null)
{
// Resolve CIFS network folder location for this node
FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) cifsServer.getConfiguration().getConfigSection(FilesystemsConfigSection.SectionName);
DiskSharedDevice diskShare = null;
SharedDeviceList shares = filesysConfig.getShares();
Enumeration<SharedDevice> shareEnum = shares.enumerateShares();
while ( shareEnum.hasMoreElements() && diskShare == null) {
SharedDevice curShare = shareEnum.nextElement();
if ( curShare.getContext() instanceof ContentContext)
diskShare = (DiskSharedDevice) curShare;
}
// Resolve CIFS network folder location for this node
FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection)cifsServer.getConfiguration().getConfigSection(FilesystemsConfigSection.SectionName);
DiskSharedDevice diskShare = null;
SharedDeviceList shares = filesysConfig.getShares();
Enumeration<SharedDevice> shareEnum = shares.enumerateShares();
while (shareEnum.hasMoreElements() && diskShare == null)
{
SharedDevice curShare = shareEnum.nextElement();
if (curShare.getContext() instanceof ContentContext)
{
diskShare = (DiskSharedDevice)curShare;
}
}
if (diskShare != null)
{
ContentContext contentCtx = (ContentContext) diskShare.getContext();
ContentContext contentCtx = (ContentContext)diskShare.getContext();
NodeRef rootNode = contentCtx.getRootNode();
try
{
@@ -1038,19 +1042,23 @@ public final class Utils extends StringUtils
*/
public static String getUserAgent(FacesContext context)
{
final String userAgent = context.getExternalContext().getRequestHeaderMap().get("User-Agent").toString();
Object userAgent = context.getExternalContext().getRequestHeaderMap().get("User-Agent");
if (userAgent != null)
{
if (userAgent.indexOf("Firefox/") != -1)
if (userAgent.toString().indexOf("Firefox/") != -1)
{
return USER_AGENT_FIREFOX;
}
else if (userAgent.indexOf("MSIE") != -1)
else if (userAgent.toString().indexOf("MSIE") != -1)
{
return USER_AGENT_MSIE;
}
else
{
return userAgent.toString();
}
}
return userAgent;
return "";
}
/**

View File

@@ -108,7 +108,7 @@ public class UIDataPager extends UICommand
String beginTag = "<span";
String endTag = "</span>";
String divStyle = "";
String inputStyle = "height:18px;";
String inputStyle = "height:13px;";
String imageVericalAlign = null;
String imageStyle = "margin-top:0px;";
StringBuilder inputPageNumber = new StringBuilder(128);
@@ -126,14 +126,20 @@ public class UIDataPager extends UICommand
beginTag = "<div";
endTag = "</div>";
divStyle = "padding:1px;";
inputStyle = "height:18px; vertical-align:middle;";
inputStyle = "height:13px; vertical-align:middle;";
imageVericalAlign = "middle";
imageStyle = "margin-top:0px;";
inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
inputPageNumber.append("onkeydown=\"").append(generateIE6InputOnkeydownScript()).append("\" ");
inputPageNumber.append("id=\"").append(getPageInputId()).append("\" />");
}
else
{
inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
inputPageNumber.append("onkeyup=\"").append(generateInputOnkeyupScript()).append("\" ");
inputPageNumber.append("onkeydown=\"").append(generateInputOnkeydownScript()).append("\" ");
inputPageNumber.append("id=\"").append(getPageInputId()).append("\" />");
}
inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
inputPageNumber.append("onkeyup=\"").append(generateInputOnkeyupScript()).append("\" ");
inputPageNumber.append("onkeydown=\"").append(generateInputOnkeydownScript()).append("\" ");
inputPageNumber.append("id=\"").append(getPageInputId()).append("\" />");
}
buf.append(beginTag);
@@ -584,7 +590,9 @@ public class UIDataPager extends UICommand
script.append(" else if (e) keycode = e.which;");
script.append(" if (keycode == 13)");
script.append(" {");
script.append(" var inputControl = document.getElementById('").append(getPageInputId()).append("');");
script.append(" var inputControl = $('").append(getPageInputId()).append("');");
script.append(" var dialogForm = $('dialog');");
script.append(" if (dialogForm) {dialogForm.removeProperty('onsubmit');}");
script.append(" var val = parseInt(inputControl.value);");
script.append(" if (val == 'NaN' || document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("']==undefined)");
script.append(" { inputControl.value = 1; return false; }");
@@ -614,6 +622,43 @@ public class UIDataPager extends UICommand
script.append(" else if (e) keycode = e.which;");
script.append(" var keychar = String.fromCharCode(keycode);");
script.append(" var numcheck = /\\d/;");
script.append(" var dialogForm = $('dialog');");
script.append(" if (dialogForm && keycode==13) { ");
script.append(" dialogForm.setProperty('onsubmit','return false;')");
script.append(" }");
script.append(" return keycode==13 || keycode==8 || keycode==37 || keycode==39 || keycode==46 || (keycode>=96 && keycode<=105) || numcheck.test(keychar);");
script.append("}; return onlyDigits(event);");
return script.toString();
}
/**
* Output the JavaScript event script to handle onkeydown event in the Page Number input (For IE6 browser).
* It handles only digits and some 'useful' keys.
* @return JavaScript code
*/
private String generateIE6InputOnkeydownScript()
{
final String formClientId = Utils.getParentForm(getFacesContext(), this).getClientId(getFacesContext());
final StringBuilder script = new StringBuilder(128);
script.append("function onlyDigits(e)");
script.append("{");
script.append(" var keycode;");
script.append(" if (window.event) keycode = window.event.keyCode;");
script.append(" else if (e) keycode = e.which;");
script.append(" var keychar = String.fromCharCode(keycode);");
script.append(" var numcheck = /\\d/;");
script.append(" if (keycode == 13)");
script.append(" {");
script.append(" var inputControl = $('").append(getPageInputId()).append("');");
script.append(" var val = parseInt(inputControl.value);");
script.append(" if (val == 'NaN' || document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("']==undefined)");
script.append(" { inputControl.value = 1; return false; }");
script.append(" else");
script.append(" { val = (val-1)>=0 ? val-1 : 0; ");
script.append(" document.forms['").append(formClientId).append("']['").append(getHiddenFieldName()).append("'].value=val;");
script.append(" document.forms['").append(formClientId).append("'].submit(); return false;");
script.append(" }");
script.append(" }");
script.append(" return keycode==13 || keycode==8 || keycode==37 || keycode==39 || keycode==46 || (keycode>=96 && keycode<=105) || numcheck.test(keychar);");
script.append("}; return onlyDigits(event);");
return script.toString();

View File

@@ -61,7 +61,7 @@ public class PageTag extends TagSupport
"/scripts/menu.js",
// webdav javascript
"/scripts/webdav.js",
// functional for window.onload
// functionality for window.onload
"/scripts/onload.js",
// base yahoo file
"/scripts/ajax/yahoo/yahoo/yahoo-min.js",
@@ -282,7 +282,7 @@ public class PageTag extends TagSupport
out.write("');");
// generate window onload code
out.write(getWindowOnloadCode());
generateWindowOnloadCode(out);
out.write("</script>\n"); // end - generate naked javascript code
@@ -366,34 +366,41 @@ public class PageTag extends TagSupport
}
/**
* This method generate code for setting window.onload reference if we need (we need to open WebDav or Cifs url or may be else)
* Using javascript code(function onloadFunc) from onload.js file
* This method generate code for setting window.onload reference as
* we need to open WebDav or CIFS URL in a new window.
*
* Executes via javascript code(function onloadFunc()) in "onload.js" include file.
*
* @return Returns window.onload javascript code
*/
private String getWindowOnloadCode()
private static void generateWindowOnloadCode(Writer out)
throws IOException
{
FacesContext fc = FacesContext.getCurrentInstance();
if (fc != null)
{
CCProperties ccProps = (CCProperties) FacesHelper.getManagedBean(fc, "CCProperties");
StringBuilder onloadCode = new StringBuilder();
CCProperties ccProps = (CCProperties)FacesHelper.getManagedBean(fc, "CCProperties");
if (ccProps.getWebdavUrl() != null || ccProps.getCifsPath() != null)
{
String webdavUrl = (ccProps.getWebdavUrl() != null) ? (ccProps.getWebdavUrl()) : ("");
String cifsPath = (ccProps.getCifsPath() != null) ? (ccProps.getCifsPath()) : ("");
out.write("window.onload=onloadFunc('");
if (ccProps.getWebdavUrl() != null)
{
out.write(ccProps.getWebdavUrl());
}
out.write("','");
if (ccProps.getCifsPath() != null)
{
String val = ccProps.getCifsPath();
val = Utils.replace(val, "\\", "\\\\"); // encode escape character
val = Utils.replace(val, "'", "\\'"); // encode single quote as we wrap string with that
out.write(val);
}
out.write("');");
onloadCode.append("window.onload=onloadFunc('").append(webdavUrl).append("','").append(cifsPath).append("');");
ccProps.setCifsPath(null); // we need reset cifsPath flag
ccProps.setWebdavUrl(null); // we need reset webdavUrl flag
// reset session bean state
ccProps.setCifsPath(null);
ccProps.setWebdavUrl(null);
}
return onloadCode.toString();
}
else
{
return "";
}
}
}