1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.internal.tools.ListenersTools1_2;
12 import org.rcfaces.core.component.FileItemComponent;
13 import org.rcfaces.core.internal.tools.ListenersTools;
14 import javax.faces.context.FacesContext;
15
16 public abstract class FileItemTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(FileItemTag.class);
20
21 private ValueExpression charSet;
22 private ValueExpression src;
23 public final void setCharSet(ValueExpression charSet) {
24 this.charSet = charSet;
25 }
26
27 public final void setSrc(ValueExpression src) {
28 this.src = src;
29 }
30
31 protected void setProperties(UIComponent uiComponent) {
32 if (LOG.isDebugEnabled()) {
33 LOG.debug(" charSet='"+charSet+"'");
34 LOG.debug(" src='"+src+"'");
35 }
36 if ((uiComponent instanceof FileItemComponent)==false) {
37 if (uiComponent instanceof UIViewRoot) {
38 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
39 }
40 throw new IllegalStateException("Component specified by tag is not instanceof of 'FileItemComponent'.");
41 }
42
43 super.setProperties(uiComponent);
44
45 FileItemComponent component = (FileItemComponent) uiComponent;
46 FacesContext facesContext = getFacesContext();
47
48 if (charSet != null) {
49 if (charSet.isLiteralText()==false) {
50 component.setValueExpression(Properties.CHAR_SET, charSet);
51
52 } else {
53 component.setCharSet(charSet.getExpressionString());
54 }
55 }
56
57 if (src != null) {
58 if (src.isLiteralText()==false) {
59 component.setValueExpression(Properties.SRC, src);
60
61 } else {
62 component.setSrc(src.getExpressionString());
63 }
64 }
65 }
66
67 public void release() {
68 charSet = null;
69 src = null;
70
71 super.release();
72 }
73
74 }