Fix ups and improvements to latest ML UI additions

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5932 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-06-13 11:26:44 +00:00
parent add54d575c
commit c240fc2948
8 changed files with 96 additions and 228 deletions

View File

@@ -31,17 +31,20 @@ import javax.faces.model.SelectItem;
import org.alfresco.i18n.I18NUtil; import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.ml.MultilingualContentService; import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.UserPreferencesBean; import org.alfresco.web.bean.UserPreferencesBean;
import org.alfresco.web.bean.content.AddContentDialog; import org.alfresco.web.bean.content.AddContentDialog;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.ui.common.Utils;
/** /**
* Dialog bean to upload a new document and to add it to an existing MLContainer. * Dialog bean to upload a new document and to add it to an existing MLContainer.
* *
* @author yanipig * @author yanipig
*/ */
public class AddTranslationlDialog extends AddContentDialog public class AddTranslationDialog extends AddContentDialog
{ {
private MultilingualContentService multilingualContentService; private MultilingualContentService multilingualContentService;
private UserPreferencesBean userPreferencesBean; private UserPreferencesBean userPreferencesBean;
@@ -82,7 +85,19 @@ public class AddTranslationlDialog extends AddContentDialog
// add a new translation // add a new translation
multilingualContentService.addTranslation(this.createdNode, this.mlTranslation, I18NUtil.parseLocale(this.language)); multilingualContentService.addTranslation(this.createdNode, this.mlTranslation, I18NUtil.parseLocale(this.language));
this.browseBean.setDocument(new Node(this.createdNode)); // Get the content data of the translation
ContentData contentData = fileFolderService.getReader(this.createdNode).getContentData();
Node createdNode = new Node(this.createdNode);
Map<String, Object> browseProp = createdNode.getProperties();
browseProp.put("size", contentData.getSize());
browseProp.put("mimetype", contentData.getMimetype());
browseProp.put("cm:content", contentData);
browseProp.put("fileType32", Utils.getFileTypeImage(createdNode.getName(), false));
browseProp.put("url", DownloadContentServlet.generateDownloadURL(this.createdNode, createdNode.getName()));
this.browseBean.setDocument(createdNode);
return outcome; return outcome;
} }

View File

@@ -91,7 +91,7 @@ public class AddTranslationWithoutContentDialog extends BaseDialogBean
nodeService.setProperty(newTranslation, ContentModel.PROP_AUTHOR, author); nodeService.setProperty(newTranslation, ContentModel.PROP_AUTHOR, author);
nodeService.setProperty(newTranslation, ContentModel.PROP_TITLE, title); nodeService.setProperty(newTranslation, ContentModel.PROP_TITLE, title);
// Get the content data of the // Get the content data of the new translation
ContentData newTranslationContentData = fileFolderService.getReader(newTranslation).getContentData(); ContentData newTranslationContentData = fileFolderService.getReader(newTranslation).getContentData();
// set the current browse node // set the current browse node

View File

@@ -159,7 +159,7 @@ public class MakeMultilingualDialog extends BaseDialogBean
} }
else else
{ {
AddTranslationlDialog dialog = (AddTranslationlDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog"); AddTranslationDialog dialog = (AddTranslationDialog) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog");
dialog.start(null); dialog.start(null);
return "addTranslation"; return "addTranslation";
} }

View File

@@ -28,8 +28,10 @@ import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import javax.faces.component.UIOutput; import javax.faces.component.UIOutput;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.el.ValueBinding; import javax.faces.el.ValueBinding;
/** /**
@@ -124,19 +126,48 @@ public class UIOutputText extends UIOutput
return; return;
} }
ResponseWriter out = context.getResponseWriter(); Object value = getValue();
if (value != null)
{
Converter converter = getConverter();
if (converter != null)
{
value = converter.getAsString(context, this, value);
}
String output = null; ResponseWriter out = context.getResponseWriter();
if (isEncodeForJavaScript()) if (isEncodeForJavaScript())
{ {
output = URLEncoder.encode((String)getValue(), "UTF-8").replace('+', ' '); out.write( URLEncoder.encode((String)getValue(), "UTF-8").replace('+', ' ') );
} }
else else
{ {
output = (String)getValue(); String style = (String)getAttributes().get("style");
String styleClass = (String)getAttributes().get("styleClass");
if (style != null || styleClass != null)
{
out.write("<span");
if (style != null)
{
out.write(" style='");
out.write(style);
out.write('\'');
}
if (styleClass != null)
{
out.write(" class=");
out.write(styleClass);
}
out.write('>');
out.write(value.toString());
out.write("</span>");
}
else
{
out.write(value.toString());
}
}
} }
out.write(output);
} }
} }

View File

@@ -1809,6 +1809,18 @@
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute> <attribute>
<name>encodeForJavaScript</name> <name>encodeForJavaScript</name>
<required>false</required> <required>false</required>
@@ -1978,195 +1990,8 @@
</attribute> </attribute>
</tag> </tag>
<!-- output_text -->
<tag>
<name>outputTextExprEnable</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlOutputTextTag</tag-class>
<body-content>JSP</body-content>
<description>
Renders the value of the associated UIOutput component. If this
element has an ID or CSS style properties, the text is wrapped in
a span element.
Unless otherwise specified, all attributes accept static values
or EL expressions.
</description>
<!-- UIOutput attributes -->
<!-- UIComponent attributes -->
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
<description>
The developer-assigned ID of this component. The ID must be unique
within the scope of the tag's enclosing naming container (e.g.
h:form or f:subview). This value must be a static value.
</description>
</attribute>
<attribute>
<name>binding</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
<description>
Identifies a backing bean property (of type UIComponent or appropriate
subclass) to bind to this component instance. This value must be an
EL expression.
</description>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
<description>
A boolean value that indicates whether this component should be rendered.
Default value: true.
</description>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
<description>
The initial value of this component. This value is generally
set as a value-binding in the form #{myBean.myProperty}, where
myProperty can be any data-type of Java (also user-defined data-types),
if a converter for this data-type exists.
Special cases:
1) f:selectItems - value needs to bind to a list (or an array) of javax.faces.model.SelectItem-instances
2) components implementing UISelectMany (e.g. h:selectManyCheckbox) -
value needs to bind to a list (or an array) of values, where the values need to be
of the same data-type as the choices of the associated f:selectItems-component
3) components implementing UIData (e.g. h:dataTable) -
value needs to bind to a list (or an array) of values,
which will be iterated over when the data-table is processed
</description>
</attribute>
<attribute>
<name>converter</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<type>java.lang.String</type>
<description>
An expression that specifies the Converter for this component.
If the value binding expression is a String, the String is used
as an ID to look up a Converter. If the value binding expression
is a Converter, uses that instance as the converter.
The value can either be a static value (ID case only) or an EL expression.
</description>
</attribute>
<!-- HTML 4.0 universal attributes -->
<attribute>
<name>dir</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: The direction of text display, either 'ltr' (left-to-right) or 'rtl' (right-to-left).</description>
</attribute>
<attribute>
<name>lang</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: The base language of this document.</description>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: CSS styling instructions.</description>
</attribute>
<attribute>
<name>title</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: An advisory title for this element. Often used by the user agent as a tooltip.</description>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>The CSS class for this element. Corresponds to the HTML 'class' attribute.</description>
</attribute>
<!-- HTML 4.0 event-handler attributes -->
<attribute>
<name>onclick</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the element is clicked.</description>
</attribute>
<attribute>
<name>ondblclick</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the element is double-clicked.</description>
</attribute>
<attribute>
<name>onmousedown</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the pointing device is pressed over this element.</description>
</attribute>
<attribute>
<name>onmouseup</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the pointing device is released over this element.</description>
</attribute>
<attribute>
<name>onmouseover</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the pointing device is moved into this element.</description>
</attribute>
<attribute>
<name>onmousemove</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the pointing device is moved while it is in this element.</description>
</attribute>
<attribute>
<name>onmouseout</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when the pointing device is moves out of this element.</description>
</attribute>
<attribute>
<name>onkeypress</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when a key is pressed over this element.</description>
</attribute>
<attribute>
<name>onkeydown</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when a key is pressed down over this element.</description>
</attribute>
<attribute>
<name>onkeyup</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>HTML: Script to be invoked when a key is released over this element.</description>
</attribute>
<attribute>
<name>escape</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description>
Indicates whether rendered markup should be escaped.
Default: true
</description>
</attribute>
</tag>
<!-- graphic_image --> <!-- graphic_image -->
<!-- IMPORTANT NOTE: this is copied from the MyFaces tld definition so the ID attribute can use rtexprvalue=true -->
<tag> <tag>
<name>graphicImageExprEnable</name> <name>graphicImageExprEnable</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlGraphicImageTag</tag-class> <tag-class>org.apache.myfaces.taglib.html.HtmlGraphicImageTag</tag-class>

View File

@@ -128,7 +128,7 @@
The bean that add a translation with a content The bean that add a translation with a content
</description> </description>
<managed-bean-name>AddTranslationDialog</managed-bean-name> <managed-bean-name>AddTranslationDialog</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.ml.AddTranslationlDialog</managed-bean-class> <managed-bean-class>org.alfresco.web.bean.ml.AddTranslationDialog</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope> <managed-bean-scope>session</managed-bean-scope>
<managed-property> <managed-property>
<property-name>multilingualContentService</property-name> <property-name>multilingualContentService</property-name>

View File

@@ -33,11 +33,11 @@
<%@ page import="org.alfresco.web.app.Application" %> <%@ page import="org.alfresco.web.app.Application" %>
<%@ page import="org.alfresco.web.app.servlet.FacesHelper" %> <%@ page import="org.alfresco.web.app.servlet.FacesHelper" %>
<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %> <%@ page import="org.alfresco.web.ui.common.PanelGenerator" %>
<%@ page import="org.alfresco.web.bean.ml.AddTranslationlDialog" %> <%@ page import="org.alfresco.web.bean.ml.AddTranslationDialog" %>
<% <%
boolean fileUploaded = false; boolean fileUploaded = false;
AddTranslationlDialog dialog = (AddTranslationlDialog)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog"); AddTranslationDialog dialog = (AddTranslationDialog)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AddTranslationDialog");
if (dialog != null && dialog.getFileName() != null) if (dialog != null && dialog.getFileName() != null)
{ {

View File

@@ -259,24 +259,24 @@
<%-- edition label --%> <%-- edition label --%>
<a:column id="column-edition-label${idx}" width="100" style="text-align:left"> <a:column id="column-edition-label${idx}" width="100" style="text-align:left">
<a:outputTextExprEnable id="edition-label${idx}" value="#{ed.editionLabel}"/> <a:outputText id="edition-label${idx}" value="#{ed.editionLabel}"/>
</a:column> </a:column>
<%-- edition notes --%> <%-- edition notes --%>
<a:column id="column-edition-notes${idx}" width="200" style="text-align:left"> <a:column id="column-edition-notes${idx}" width="200" style="text-align:left">
<a:outputTextExprEnable id="edition-notes${idx}" value="#{ed.editionNotes}" /> <a:outputText id="edition-notes${idx}" value="#{ed.editionNotes}" />
</a:column> </a:column>
<%-- edition author --%> <%-- edition author --%>
<a:column id="column-edition-author${idx}" style="text-align:left"> <a:column id="column-edition-author${idx}" style="text-align:left">
<a:outputTextExprEnable id="edition-author${idx}" value="#{ed.editionAuthor}" /> <a:outputText id="edition-author${idx}" value="#{ed.editionAuthor}" />
</a:column> </a:column>
<%-- edition date --%> <%-- edition date --%>
<a:column id="column-edition-date${idx}" style="text-align:left; white-space:nowrap"> <a:column id="column-edition-date${idx}" style="text-align:left; white-space:nowrap">
<a:outputTextExprEnable id="edition-date${idx}" value="#{ed.editionDate}"> <a:outputText id="edition-date${idx}" value="#{ed.editionDate}">
<a:convertXMLDate type="both" pattern="#{msg.date_pattern}" /> <a:convertXMLDate type="both" pattern="#{msg.date_pattern}" />
</a:outputTextExprEnable> </a:outputText>
</a:column> </a:column>
</a:richList> </a:richList>
@@ -292,9 +292,6 @@
<%-- Icon details view mode --%> <%-- Icon details view mode --%>
<a:column id="column-view-mode${idx}" primary="true" width="20" style="padding:2px;"> <a:column id="column-view-mode${idx}" primary="true" width="20" style="padding:2px;">
<f:facet name="header">
<a:outputTextExprEnable id="translation-image-title${idx}" value="" styleClass="header"/>
</f:facet>
<a:graphicImageExprEnable id="translation-image${idx}" url="/images/filetypes/_default.gif" /> <a:graphicImageExprEnable id="translation-image${idx}" url="/images/filetypes/_default.gif" />
</a:column> </a:column>
@@ -303,15 +300,15 @@
<f:facet name="header"> <f:facet name="header">
<a:sortLink id="sort-name${idx}" label="#{msg.name}" value="versionName" mode="case-insensitive" styleClass="header"/> <a:sortLink id="sort-name${idx}" label="#{msg.name}" value="versionName" mode="case-insensitive" styleClass="header"/>
</f:facet> </f:facet>
<a:outputTextExprEnable id="translation-name${idx}" value="#{tr.versionName}"/> <a:outputText id="translation-name${idx}" value="#{tr.versionName}"/>
</a:column> </a:column>
<%-- Versionned description --%> <%-- Versionned description --%>
<a:column id="column-description${idx}" width="200" style="text-align:left"> <a:column id="column-description${idx}" width="200" style="text-align:left">
<f:facet name="header"> <f:facet name="header">
<a:outputTextExprEnable id="desc-title${idx}" value="#{msg.description}" styleClass="header"/> <a:outputText id="desc-title${idx}" value="#{msg.description}" styleClass="header"/>
</f:facet> </f:facet>
<a:outputTextExprEnable id="translation-description${idx}" value="#{tr.versionDescription}" /> <a:outputText id="translation-description${idx}" value="#{tr.versionDescription}" />
</a:column> </a:column>
<%-- Versionned creation date --%> <%-- Versionned creation date --%>
@@ -319,9 +316,9 @@
<f:facet name="header"> <f:facet name="header">
<a:sortLink id="sort-cr-date${idx}" label="#{msg.created}" value="versionCreatedDate" mode="case-insensitive" styleClass="header"/> <a:sortLink id="sort-cr-date${idx}" label="#{msg.created}" value="versionCreatedDate" mode="case-insensitive" styleClass="header"/>
</f:facet> </f:facet>
<a:outputTextExprEnable id="translation-created-date${idx}" value="#{tr.versionCreatedDate}"> <a:outputText id="translation-created-date${idx}" value="#{tr.versionCreatedDate}">
<a:convertXMLDate type="both" pattern="#{msg.date_pattern}" /> <a:convertXMLDate type="both" pattern="#{msg.date_pattern}" />
</a:outputTextExprEnable> </a:outputText>
</a:column> </a:column>
<%-- Versionned modified date --%> <%-- Versionned modified date --%>
@@ -329,9 +326,9 @@
<f:facet name="header"> <f:facet name="header">
<a:sortLink id="sort-mod-date${idx}" label="#{msg.modified}" value="versionModifiedDate" mode="case-insensitive" styleClass="header"/> <a:sortLink id="sort-mod-date${idx}" label="#{msg.modified}" value="versionModifiedDate" mode="case-insensitive" styleClass="header"/>
</f:facet> </f:facet>
<a:outputTextExprEnable id="translation-modif-date${idx}" value="#{tr.versionModifiedDate}"> <a:outputText id="translation-modif-date${idx}" value="#{tr.versionModifiedDate}">
<a:convertXMLDate type="both" pattern="#{msg.date_pattern}" /> <a:convertXMLDate type="both" pattern="#{msg.date_pattern}" />
</a:outputTextExprEnable> </a:outputText>
</a:column> </a:column>
<%-- Versionned language --%> <%-- Versionned language --%>
@@ -339,13 +336,13 @@
<f:facet name="header"> <f:facet name="header">
<a:sortLink id="sort-lang${idx}" label="#{msg.language}" value="versionLanguage" mode="case-insensitive" styleClass="header"/> <a:sortLink id="sort-lang${idx}" label="#{msg.language}" value="versionLanguage" mode="case-insensitive" styleClass="header"/>
</f:facet> </f:facet>
<a:outputTextExprEnable id="translation-language${idx}" value="#{tr.versionLanguage}" /> <a:outputText id="translation-language${idx}" value="#{tr.versionLanguage}" />
</a:column> </a:column>
<%-- view actions --%> <%-- view actions --%>
<a:column id="column-action${idx}" style="text-align: left"> <a:column id="column-action${idx}" style="text-align: left">
<f:facet name="header"> <f:facet name="header">
<a:outputTextExprEnable id="translation-action${idx}" value="#{msg.actions}"/> <a:outputText id="translation-action${idx}" value="#{msg.actions}"/>
</f:facet> </f:facet>
<a:actionLink id="translation-link${idx}" value="#{msg.view}" href="#{tr.versionUrl}" target="new" /> <a:actionLink id="translation-link${idx}" value="#{msg.view}" href="#{tr.versionUrl}" target="new" />
</a:column> </a:column>