001: /**********************************************************************************
002: * $URL:https://source.sakaiproject.org/svn/osp/trunk/jsf/example/src/java/example/xml/SequenceTagHandler.java $
003: * $Id:SequenceTagHandler.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 example.xml;
021:
022: import java.io.IOException;
023:
024: import javax.faces.component.UIColumn;
025: import javax.faces.component.UIData;
026: import javax.faces.component.UIViewRoot;
027: import javax.faces.component.html.HtmlCommandButton;
028: import javax.faces.component.html.HtmlInputText;
029: import javax.faces.component.html.HtmlOutputLink;
030: import javax.faces.component.html.HtmlOutputText;
031: import javax.faces.context.FacesContext;
032: import javax.faces.el.ValueBinding;
033: import javax.faces.event.ActionEvent;
034:
035: import org.theospi.jsf.impl.DefaultXmlTagHandler;
036: import org.theospi.jsf.intf.ComponentWrapper;
037: import org.theospi.jsf.intf.XmlTagFactory;
038: import org.xml.sax.Attributes;
039:
040: /**
041: * Created by IntelliJ IDEA.
042: * User: John Ellis
043: * Date: Dec 30, 2005
044: * Time: 1:25:13 PM
045: * To change this template use File | Settings | File Templates.
046: */
047: public class SequenceTagHandler extends DefaultXmlTagHandler {
048:
049: public SequenceTagHandler(XmlTagFactory factory) {
050: super (factory);
051: }
052:
053: public ComponentWrapper startElement(FacesContext context,
054: ComponentWrapper parent, String uri, String localName,
055: String qName, Attributes attributes) throws IOException {
056: UIViewRoot root = context.getViewRoot();
057: UIData container = new UIData();
058: parent.getComponent().getChildren().add(container);
059: ValueBinding vb = context.getApplication().createValueBinding(
060: "#{testBean.subBeans}");
061: container.setValueBinding("value", vb);
062: container.setVar("testSubBean");
063: container.setId(root.createUniqueId());
064: UIColumn column = new UIColumn();
065: column.setId(root.createUniqueId());
066: container.getChildren().add(column);
067: HtmlOutputLink testLink = new HtmlOutputLink();
068: testLink.setValue("http://www.javasoft.com");
069: HtmlOutputText text = new HtmlOutputText();
070: text.setValue("test");
071: testLink.getChildren().add(text);
072: HtmlCommandButton button = new HtmlCommandButton();
073: button.setId(root.createUniqueId());
074: button.setActionListener(context.getApplication()
075: .createMethodBinding(
076: "#{testSubBean.processTestButton}",
077: new Class[] { ActionEvent.class }));
078: button.setValue("test me");
079: HtmlInputText input = new HtmlInputText();
080: input.setValueBinding("value", context.getApplication()
081: .createValueBinding("#{testSubBean.index}"));
082: input.setId(root.createUniqueId());
083: column.getChildren().add(input);
084: column.getChildren().add(button);
085: HtmlOutputText testVerbatim = new HtmlOutputText();
086: testVerbatim.setEscape(false);
087: testVerbatim.setValue("<some>");
088: column.getChildren().add(testVerbatim);
089: column.getChildren().add(testLink);
090: HtmlOutputText testVerbatim2 = new HtmlOutputText();
091: testVerbatim2.setEscape(false);
092: testVerbatim2.setValue("</some>");
093: column.getChildren().add(testVerbatim2);
094: return new ComponentWrapper(parent, column, this );
095: }
096:
097: public void characters(FacesContext context,
098: ComponentWrapper current, char[] ch, int start, int length)
099: throws IOException {
100: writeCharsToVerbatim(context, current, ch, start, length);
101: }
102:
103: public void endElement(FacesContext context,
104: ComponentWrapper current, String uri, String localName,
105: String qName) throws IOException {
106: }
107: }
|