[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...
Norman Richards
norman.richards at jboss.com
Wed Feb 7 02:15:13 EST 2007
User: nrichards
Date: 07/02/07 02:15:13
Modified: src/pdf/org/jboss/seam/pdf/ui ITextComponent.java
UIDocument.java UITable.java
Log:
add header facet for header/footer info
Revision Changes Path
1.9 +26 -12 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ITextComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/ITextComponent.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- ITextComponent.java 5 Feb 2007 06:23:25 -0000 1.8
+++ ITextComponent.java 7 Feb 2007 07:15:13 -0000 1.9
@@ -6,11 +6,7 @@
import javax.faces.el.ValueBinding;
import java.io.*;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-
import org.jboss.seam.ui.JSF;
import com.lowagie.text.*;
@@ -21,7 +17,8 @@
public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf";
protected String inFacet;
- protected Map<String,Object> facets = new HashMap<String,Object>();
+ protected Object currentFacet;
+ //protected Map<String,Object> facets = new HashMap<String,Object>();
/**
* get the current Itext object
@@ -53,7 +50,8 @@
}
public void handleFacet(String facetName, Object obj) {
- facets.put(facetName,obj);
+ currentFacet = obj;
+ // facets.put(facetName,obj);
}
/**
@@ -115,6 +113,28 @@
}
+ public Object processFacet(String facetName) {
+ if (inFacet!=null && inFacet.equals(facetName)) {
+ return null;
+ }
+
+ UIComponent facet = this.getFacet(facetName);
+ Object result = null;
+ if (facet != null) {
+ currentFacet = null;
+ inFacet = facetName;
+ try {
+ encode(FacesContext.getCurrentInstance(), facet);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ inFacet = null;
+ result = currentFacet;
+ currentFacet = null;
+ }
+ }
+ return result;
+ }
public Object valueBinding(FacesContext context,
String property,
@@ -163,12 +183,6 @@
public void encodeChildren(FacesContext context)
throws IOException
{
- for (String name: (Collection<String>) this.getFacets().keySet()) {
- inFacet = name;
- encode(context, this.getFacet(name));
- inFacet = null;
- }
-
for (UIComponent child: (List<UIComponent>) this.getChildren()) {
// ugly hack to be able to capture facelets text
if (child.getFamily().equals("facelets.LiteralText")) {
1.16 +23 -0 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIDocument.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- UIDocument.java 4 Feb 2007 19:10:34 -0000 1.15
+++ UIDocument.java 7 Feb 2007 07:15:13 -0000 1.16
@@ -6,6 +6,7 @@
import org.jboss.seam.pdf.DocumentStore;
import org.jboss.seam.pdf.DocumentData.DocType;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.context.*;
@@ -214,6 +215,8 @@
initMetaData(context);
+ processHeaders();
+
document.open();
} catch (DocumentException e) {
throw new RuntimeException(e);
@@ -243,6 +246,26 @@
}
}
+ private void processHeaders() {
+ Object facet = getFacet("header");
+
+ if (facet == null) {
+ return;
+ }
+
+ if (facet instanceof UIComponent) {
+ try {
+ encode(FacesContext.getCurrentInstance(), (UIComponent) facet);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ }
+
+
+
private String baseNameForViewId(String viewId) {
int pos = viewId.lastIndexOf("/");
if (pos != -1) {
1.8 +2 -1 jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UITable.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UITable.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- UITable.java 24 Jan 2007 17:39:16 -0000 1.7
+++ UITable.java 7 Feb 2007 07:15:13 -0000 1.8
@@ -204,7 +204,8 @@
}
public PdfPCell getDefaultCellFacet() {
- Object facet = facets.get("defaultCell");
+ Object facet = processFacet("defaultCell");
+
if (facet != null) {
if (!(facet instanceof PdfPCell)) {
throw new RuntimeException("UITable defaultCell facet must be a PdfPCell - found " + facet.getClass());
More information about the jboss-cvs-commits
mailing list