mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
cleanup to jsps which render the xform. using a tag to render, removing all the java code. much prettier.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4168 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,10 +41,13 @@ import org.alfresco.web.bean.FileUploadBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.templating.OutputUtil;
|
||||
import org.alfresco.web.templating.TemplateType;
|
||||
import org.alfresco.web.templating.TemplateInputMethod;
|
||||
import org.alfresco.web.templating.TemplatingService;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* Bean backing the edit pages for a AVM node content.
|
||||
@@ -204,7 +207,51 @@ public class AVMEditBean
|
||||
return MessageFormat.format(msg, new Object[] {getFileName()});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the template type when in the context of editing an xml asset.
|
||||
*/
|
||||
public TemplateType getTemplateType()
|
||||
{
|
||||
final NodeRef ttNodeRef = (NodeRef)
|
||||
this.nodeService.getProperty(this.getAvmNode().getNodeRef(),
|
||||
WCMModel.PROP_FORM_DERIVED_FROM);
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
return ts.getTemplateType(ttNodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the wrapper instance data for feeding the xml
|
||||
* content to the form processor.
|
||||
*/
|
||||
public TemplateInputMethod.InstanceData getInstanceData()
|
||||
{
|
||||
final TemplateType tt = this.getTemplateType();
|
||||
final TemplateInputMethod tim = tt.getInputMethods().get(0);
|
||||
return new TemplateInputMethod.InstanceData()
|
||||
{
|
||||
private final TemplatingService ts = TemplatingService.getInstance();
|
||||
|
||||
public Document getContent()
|
||||
{
|
||||
try
|
||||
{
|
||||
final String content = AVMEditBean.this.getEditorOutput();
|
||||
return content != null ? this.ts.parseXML(content) : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContent(final Document d)
|
||||
{
|
||||
AVMEditBean.this.setEditorOutput(this.ts.writeXMLToString(d));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
|
@@ -47,10 +47,12 @@ import org.alfresco.web.bean.content.BaseContentWizard;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.templating.OutputUtil;
|
||||
import org.alfresco.web.templating.TemplateInputMethod;
|
||||
import org.alfresco.web.templating.TemplateType;
|
||||
import org.alfresco.web.templating.TemplatingService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Create Web Content Wizard" dialog
|
||||
@@ -303,6 +305,37 @@ public class CreateWebContentWizard extends BaseContentWizard
|
||||
{
|
||||
this.templateTypeName = templateTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the wrapper instance data for feeding the xml
|
||||
* content to the form processor.
|
||||
*/
|
||||
public TemplateInputMethod.InstanceData getInstanceData()
|
||||
{
|
||||
return new TemplateInputMethod.InstanceData()
|
||||
{
|
||||
private final TemplatingService ts = TemplatingService.getInstance();
|
||||
|
||||
public Document getContent()
|
||||
{
|
||||
try
|
||||
{
|
||||
final String content = CreateWebContentWizard.this.getContent();
|
||||
return content != null ? this.ts.parseXML(content) : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContent(final Document d)
|
||||
{
|
||||
CreateWebContentWizard.this.setContent(ts.writeXMLToString(d));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
|
@@ -24,37 +24,39 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Encapsulation of a template type.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public interface TemplateType
|
||||
extends Serializable
|
||||
extends Serializable
|
||||
{
|
||||
|
||||
/** the name of the template, which must be unique within the TemplatingService */
|
||||
public String getName();
|
||||
/** the name of the template, which must be unique within the TemplatingService */
|
||||
public String getName();
|
||||
|
||||
/** the root tag to use within the schema */
|
||||
public String getRootTagName();
|
||||
/** the root tag to use within the schema */
|
||||
public String getRootTagName();
|
||||
|
||||
/** the xml schema for this template type */
|
||||
public Document getSchema();
|
||||
/** the xml schema for this template type */
|
||||
public Document getSchema();
|
||||
|
||||
public NodeRef getNodeRef();
|
||||
|
||||
//XXXarielb not used currently and not sure if it's necessary...
|
||||
// public void addInputMethod(final TemplateInputMethod in);
|
||||
//XXXarielb not used currently and not sure if it's necessary...
|
||||
// public void addInputMethod(final TemplateInputMethod in);
|
||||
|
||||
/**
|
||||
* Provides a set of input methods for this template.
|
||||
*/
|
||||
public List<TemplateInputMethod> getInputMethods();
|
||||
/**
|
||||
* Provides a set of input methods for this template.
|
||||
*/
|
||||
public List<TemplateInputMethod> getInputMethods();
|
||||
|
||||
/**
|
||||
* adds an output method to this template type.
|
||||
*/
|
||||
public void addOutputMethod(TemplateOutputMethod output);
|
||||
/**
|
||||
* adds an output method to this template type.
|
||||
*/
|
||||
public void addOutputMethod(TemplateOutputMethod output);
|
||||
|
||||
/**
|
||||
* Provides the set of output methods for this template.
|
||||
*/
|
||||
public List<TemplateOutputMethod> getOutputMethods();
|
||||
/**
|
||||
* Provides the set of output methods for this template.
|
||||
*/
|
||||
public List<TemplateOutputMethod> getOutputMethods();
|
||||
}
|
||||
|
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.alfresco.web.ui.wcm.component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.el.ValueBinding;
|
||||
|
||||
import org.alfresco.web.templating.*;
|
||||
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class UIFormProcessor extends SelfRenderingComponent
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(UIFormProcessor.class);
|
||||
|
||||
|
||||
private TemplateInputMethod.InstanceData formInstanceData = null;
|
||||
|
||||
private TemplateType form = null;
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Component implementation
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponent#getFamily()
|
||||
*/
|
||||
public String getFamily()
|
||||
{
|
||||
return "org.alfresco.faces.FormProcessor";
|
||||
}
|
||||
|
||||
public void restoreState(FacesContext context, Object state)
|
||||
{
|
||||
final Object values[] = (Object[])state;
|
||||
// standard component attributes are restored by the super class
|
||||
super.restoreState(context, values[0]);
|
||||
this.formInstanceData = (TemplateInputMethod.InstanceData)values[1];
|
||||
this.form = (TemplateType)values[2];
|
||||
}
|
||||
|
||||
public Object saveState(FacesContext context)
|
||||
{
|
||||
final Object values[] = {
|
||||
// standard component attributes are saved by the super class
|
||||
super.saveState(context),
|
||||
this.formInstanceData,
|
||||
this.form
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void encodeBegin(final FacesContext context)
|
||||
throws IOException
|
||||
{
|
||||
if (isRendered() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
final TemplateType form = this.getForm();
|
||||
final TemplateInputMethod.InstanceData formInstanceData = this.getFormInstanceData();
|
||||
final TemplateInputMethod tim = form.getInputMethods().get(0);
|
||||
tim.generate(formInstanceData, form, out);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Strongly typed component property accessors
|
||||
|
||||
/**
|
||||
* Returns the instance data to render
|
||||
*
|
||||
* @return The instance data to render
|
||||
*/
|
||||
public TemplateInputMethod.InstanceData getFormInstanceData()
|
||||
{
|
||||
final ValueBinding vb = getValueBinding("formInstanceData");
|
||||
if (vb != null)
|
||||
{
|
||||
this.formInstanceData = (TemplateInputMethod.InstanceData)vb.getValue(getFacesContext());
|
||||
}
|
||||
|
||||
return this.formInstanceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the instance data to render
|
||||
*
|
||||
* @param formInstanceData The instance data to render
|
||||
*/
|
||||
public void setFormInstanceData(final TemplateInputMethod.InstanceData formInstanceData)
|
||||
{
|
||||
this.formInstanceData = formInstanceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the form
|
||||
*
|
||||
* @return The form
|
||||
*/
|
||||
public TemplateType getForm()
|
||||
{
|
||||
final ValueBinding vb = getValueBinding("form");
|
||||
if (vb != null)
|
||||
{
|
||||
this.form = (TemplateType)vb.getValue(getFacesContext());
|
||||
}
|
||||
|
||||
return this.form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the form
|
||||
*
|
||||
* @param form The form
|
||||
*/
|
||||
public void setForm(final TemplateType form)
|
||||
{
|
||||
this.form = form;
|
||||
}
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.alfresco.web.ui.wcm.tag;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.el.MethodBinding;
|
||||
import javax.faces.el.ValueBinding;
|
||||
import org.alfresco.web.ui.common.tag.BaseComponentTag;
|
||||
|
||||
/**
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class FormProcessorTag extends BaseComponentTag
|
||||
{
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentTag#getComponentType()
|
||||
*/
|
||||
public String getComponentType()
|
||||
{
|
||||
return "org.alfresco.faces.FormProcessor";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentTag#getRendererType()
|
||||
*/
|
||||
public String getRendererType()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
|
||||
*/
|
||||
protected void setProperties(final UIComponent component)
|
||||
{
|
||||
super.setProperties(component);
|
||||
final Application app = this.getFacesContext().getApplication();
|
||||
if (this.instanceData != null)
|
||||
{
|
||||
assert isValueReference(this.instanceData);
|
||||
final ValueBinding vb = app.createValueBinding(this.instanceData);
|
||||
component.setValueBinding("formInstanceData", vb);
|
||||
}
|
||||
if (this.templateType != null)
|
||||
{
|
||||
assert this.isValueReference(this.templateType);
|
||||
final ValueBinding vb = app.createValueBinding(this.templateType);
|
||||
component.setValueBinding("form", vb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release()
|
||||
*/
|
||||
public void release()
|
||||
{
|
||||
super.release();
|
||||
this.instanceData = null;
|
||||
this.templateType = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance data
|
||||
*
|
||||
* @param instanceData the instance data for the processor
|
||||
*/
|
||||
public void setFormInstanceData(final String instanceData)
|
||||
{
|
||||
this.instanceData = instanceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tempalte type
|
||||
*
|
||||
* @param templateType the tempalteType for the processor.
|
||||
*/
|
||||
public void setForm(final String templateType)
|
||||
{
|
||||
this.templateType = templateType;
|
||||
}
|
||||
|
||||
private String instanceData;
|
||||
private String templateType;
|
||||
}
|
Reference in New Issue
Block a user