001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/jsf/widgets/src/java/org/theospi/jsf/component/XmlDocumentComponent.java $
003: * $Id:XmlDocumentComponent.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.theospi.jsf.component;
021:
022: import java.io.InputStream;
023:
024: import javax.faces.component.UIComponent;
025: import javax.faces.component.UIComponentBase;
026: import javax.faces.context.FacesContext;
027: import javax.faces.el.ValueBinding;
028: import javax.faces.event.AbortProcessingException;
029: import javax.faces.event.FacesEvent;
030:
031: import org.theospi.jsf.intf.XmlDocumentContainer;
032: import org.theospi.jsf.intf.XmlTagFactory;
033:
034: /**
035: * Created by IntelliJ IDEA.
036: * User: John Ellis
037: * Date: Dec 29, 2005
038: * Time: 2:28:53 PM
039: * To change this template use File | Settings | File Templates.
040: */
041: public class XmlDocumentComponent extends UIComponentBase implements
042: XmlDocumentContainer {
043:
044: private XmlTagFactory factory;
045: private InputStream xmlFile;
046: private UIComponent xmlRootComponent;
047: private String xmlFileId;
048: private String oldXmlFileId;
049: private String var;
050:
051: public XmlDocumentComponent() {
052: super ();
053: this .setRendererType("org.theospi.XmlDocument");
054: }
055:
056: public String getFamily() {
057: return "org.theospi.xml";
058: }
059:
060: public XmlTagFactory getFactory() {
061: if (factory != null)
062: return factory;
063: ValueBinding vb = getValueBinding("factory");
064: factory = (XmlTagFactory) vb.getValue(getFacesContext());
065: return factory;
066: }
067:
068: public void setFactory(XmlTagFactory factory) {
069: this .factory = factory;
070: }
071:
072: /**
073: * Any time this is called the calling method MUST close the input stream!!
074: * This has the potential of causing memory leaks if the calling method does not close the stream
075: * @return InputStream
076: */
077: public InputStream getXmlFile() {
078: ValueBinding vb = getValueBinding("xmlFile");
079: return (InputStream) vb.getValue(getFacesContext());
080: }
081:
082: public void setXmlFile(InputStream xmlFile) {
083: this .xmlFile = xmlFile;
084: }
085:
086: public UIComponent getXmlRootComponent() {
087: return xmlRootComponent;
088: }
089:
090: public void setXmlRootComponent(UIComponent xmlRootComponent) {
091: this .xmlRootComponent = xmlRootComponent;
092: }
093:
094: public String getVariableName() {
095: return getVar();
096: }
097:
098: public String getVar() {
099: return var;
100: }
101:
102: public void setVar(String var) {
103: this .var = var;
104: }
105:
106: public void broadcast(FacesEvent event)
107: throws AbortProcessingException {
108: super .broadcast(event);
109: }
110:
111: public Object saveState(FacesContext context) {
112: return super .saveState(context);
113: }
114:
115: public void restoreState(FacesContext context, Object state) {
116: super .restoreState(context, state);
117: }
118:
119: public void setTransient(boolean transientFlag) {
120: super .setTransient(transientFlag);
121: }
122:
123: public String getXmlFileId() {
124: ValueBinding vb = getValueBinding("xmlFileId");
125: if (vb != null) {
126: return (String) vb.getValue(getFacesContext());
127: }
128: return null;
129: }
130:
131: public void setXmlFileId(String xmlFileId) {
132: this .xmlFileId = xmlFileId;
133: }
134:
135: public String getOldXmlFileId() {
136: return oldXmlFileId;
137: }
138:
139: public void setOldXmlFileId(String oldXmlFileId) {
140: this.oldXmlFileId = oldXmlFileId;
141: }
142: }
|