You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/07/25 05:27:27 UTC
svn commit: r425291 [3/6] - in
/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src:
main/java/org/apache/myfaces/adfdemo/
main/java/org/apache/myfaces/adfdemo/change/
main/java/org/apache/myfaces/adfdemo/composite/ main/...
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBean.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBean.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBean.java Mon Jul 24 22:27:24 2006
@@ -13,115 +13,115 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.ValueChangeEvent;
-
-import org.apache.myfaces.adf.event.DisclosureEvent;
-import org.apache.myfaces.adf.component.core.layout.CorePanelPage;
-
-import org.apache.myfaces.adf.model.UploadedFile;
-
-public class UIBean
-{
- public UIBean()
- {
- }
-
- public CorePanelPage getPanelPage()
- {
- return _panelPage;
- }
-
- public UIBeanState getState()
- {
- return _state;
- }
-
- public void setState(UIBeanState state)
- {
- _state = state;
- }
-
- public void setPanelPage(CorePanelPage panelPage)
- {
- _panelPage = panelPage;
- }
-
- public void fileUploaded(ValueChangeEvent event)
- {
- UploadedFile file = (UploadedFile) event.getNewValue();
- if (file != null)
- {
- FacesContext context = FacesContext.getCurrentInstance();
- FacesMessage message = new FacesMessage(
- "Uploaded file " + file.getFilename() +
- " (" + file.getLength() + " bytes)");
- context.addMessage(event.getComponent().getClientId(context), message);
- }
- }
-
- public void testFailover()
- {
- FacesContext context = FacesContext.getCurrentInstance();
- Map session = context.getExternalContext().getSessionMap();
- Map.Entry writing = null;
- try
- {
- ObjectOutputStream oos =
- new ObjectOutputStream(new ByteArrayOutputStream(2 << 16));
- Iterator entries = session.entrySet().iterator();
- while (entries.hasNext())
- {
- writing = (Map.Entry) entries.next();
- oos.writeObject(writing.getValue());
- context.addMessage(null,
- new FacesMessage("Successfully serialized " + writing.getValue() + " [at " + writing.getKey() + "]"));
- }
- }
- catch (IOException ioe)
- {
- context.addMessage(null,
- new FacesMessage(FacesMessage.SEVERITY_ERROR,
- "Failed while outputting object " + writing.getValue() +
- " [at " + writing.getKey() + "]",
- ioe.getMessage()));
- }
- }
-
- //
- // For testing purposes, here's a series of methods that can
- // be EL-addressed that blow up. These exceptions should
- // be displayed somewhere (preferably in a logged error
- // message), not swallowed.
- //
-
- public String actionThatFails()
- {
- throw new IllegalStateException("Calling this action is a bad move");
- }
-
- public void listenerThatFails(ValueChangeEvent event)
- {
- throw new IllegalStateException("Using this listener is a bad move");
- }
-
- public String getFailedProperty()
- {
- throw new IllegalStateException("Getting this property is a bad move");
- }
-
-
- private CorePanelPage _panelPage;
- private UIBeanState _state;
-}
+package org.apache.myfaces.adfdemo;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+
+import org.apache.myfaces.adf.event.DisclosureEvent;
+import org.apache.myfaces.adf.component.core.layout.CorePanelPage;
+
+import org.apache.myfaces.adf.model.UploadedFile;
+
+public class UIBean
+{
+ public UIBean()
+ {
+ }
+
+ public CorePanelPage getPanelPage()
+ {
+ return _panelPage;
+ }
+
+ public UIBeanState getState()
+ {
+ return _state;
+ }
+
+ public void setState(UIBeanState state)
+ {
+ _state = state;
+ }
+
+ public void setPanelPage(CorePanelPage panelPage)
+ {
+ _panelPage = panelPage;
+ }
+
+ public void fileUploaded(ValueChangeEvent event)
+ {
+ UploadedFile file = (UploadedFile) event.getNewValue();
+ if (file != null)
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ FacesMessage message = new FacesMessage(
+ "Uploaded file " + file.getFilename() +
+ " (" + file.getLength() + " bytes)");
+ context.addMessage(event.getComponent().getClientId(context), message);
+ }
+ }
+
+ public void testFailover()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Map session = context.getExternalContext().getSessionMap();
+ Map.Entry writing = null;
+ try
+ {
+ ObjectOutputStream oos =
+ new ObjectOutputStream(new ByteArrayOutputStream(2 << 16));
+ Iterator entries = session.entrySet().iterator();
+ while (entries.hasNext())
+ {
+ writing = (Map.Entry) entries.next();
+ oos.writeObject(writing.getValue());
+ context.addMessage(null,
+ new FacesMessage("Successfully serialized " + writing.getValue() + " [at " + writing.getKey() + "]"));
+ }
+ }
+ catch (IOException ioe)
+ {
+ context.addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Failed while outputting object " + writing.getValue() +
+ " [at " + writing.getKey() + "]",
+ ioe.getMessage()));
+ }
+ }
+
+ //
+ // For testing purposes, here's a series of methods that can
+ // be EL-addressed that blow up. These exceptions should
+ // be displayed somewhere (preferably in a logged error
+ // message), not swallowed.
+ //
+
+ public String actionThatFails()
+ {
+ throw new IllegalStateException("Calling this action is a bad move");
+ }
+
+ public void listenerThatFails(ValueChangeEvent event)
+ {
+ throw new IllegalStateException("Using this listener is a bad move");
+ }
+
+ public String getFailedProperty()
+ {
+ throw new IllegalStateException("Getting this property is a bad move");
+ }
+
+
+ private CorePanelPage _panelPage;
+ private UIBeanState _state;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBeanState.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBeanState.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBeanState.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBeanState.java Mon Jul 24 22:27:24 2006
@@ -13,23 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo;
-
-public class UIBeanState implements java.io.Serializable
-{
- public UIBeanState()
- {
- }
-
- public boolean isTitleSet()
- {
- return _isTitleSet;
- }
-
- public void setTitleSet(boolean set)
- {
- _isTitleSet = set;
- }
-
- private boolean _isTitleSet;
-}
+package org.apache.myfaces.adfdemo;
+
+public class UIBeanState implements java.io.Serializable
+{
+ public UIBeanState()
+ {
+ }
+
+ public boolean isTitleSet()
+ {
+ return _isTitleSet;
+ }
+
+ public void setTitleSet(boolean set)
+ {
+ _isTitleSet = set;
+ }
+
+ private boolean _isTitleSet;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/UIBeanState.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/change/ChangeBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/change/ChangeBean.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/change/ChangeBean.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/change/ChangeBean.java Mon Jul 24 22:27:24 2006
@@ -13,381 +13,381 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.change;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.myfaces.adf.change.AddChildComponentChange;
-import org.apache.myfaces.adf.change.AddChildDocumentChange;
-import org.apache.myfaces.adf.change.SetFacetChildComponentChange;
-import org.apache.myfaces.adf.change.AttributeComponentChange;
-import org.apache.myfaces.adf.change.ChangeManager;
-import org.apache.myfaces.adf.change.ComponentChange;
-import org.apache.myfaces.adf.change.DocumentChange;
-import org.apache.myfaces.adf.change.RemoveChildComponentChange;
-import org.apache.myfaces.adf.change.RemoveFacetComponentChange;
-import org.apache.myfaces.adf.change.ReorderChildrenComponentChange;
-import org.apache.myfaces.adf.component.core.nav.CoreCommandButton;
-
-import org.apache.myfaces.adf.component.core.output.CoreObjectImage;
-import org.apache.myfaces.adf.component.core.output.CoreOutputFormatted;
-import org.apache.myfaces.adf.context.AdfFacesContext;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-
-import org.xml.sax.SAXException;
-import java.io.ByteArrayInputStream;
-
-/**
- * Managed bean for Change persistence demos.
- * @version $Name: $ ($Revision: adfrt/faces/adf-faces-demo/src/main/java/oracle/adfdemo/view/faces/change/ChangeBean.java#1 $) $Date: 16-aug-2005.15:12:29 $
- */
-public class ChangeBean
-{
- /**
- * Picks up an image randomly from a list and changes it on the objectImage.
- */
- public void modifyObjectImage(ActionEvent event)
- {
- UIComponent uic = event.getComponent().findComponent("oi1");
- String source = "/components/images/" + _images[_getRandIndex()];
- uic.getAttributes().put("source", source);
- _addAttributeChange(uic, "source", source);
- }
-
- /**
- * Picks up a string randomly from a list and changes the text attribute value
- * of the panelBox.
- */
- public void modifyPanelBox(ActionEvent event)
- {
- UIComponent uic = event.getComponent().findComponent("pb1");
- String text = _texts[_getRandIndex()];
- uic.getAttributes().put("text", text);
- _addAttributeChange(uic, "text", text);
- }
-
- /**
- * Modifies the sortable property of the column.
- */
- public void modifyColumn(ActionEvent event)
- {
- //=-=pu: 'uic1' gets null, while 'uic' gets valid component, maybe a bug ?.
- //UIComponent uic1 = event.getComponent().findComponent("c1");
- UIComponent uic2 = event.getComponent().findComponent("t1");
- UIComponent uic = uic2.findComponent("c1");
-
- Object sortableAttrib = uic.getAttributes().get("sortable");
- Boolean isSortable =
- (sortableAttrib == null)? Boolean.TRUE:(Boolean)sortableAttrib;
- Boolean newSortableValue =
- Boolean.TRUE.equals(isSortable)? Boolean.FALSE:Boolean.TRUE;
- uic.getAttributes().put("sortable", newSortableValue);
- _addAttributeChange(uic, "sortable", newSortableValue);
- }
-
- /**
- * Picks up a string randomly from a list and changes the label attribute
- * value of the inputText.
- */
- public void modifyInputText(ActionEvent event)
- {
- UIComponent uic = event.getComponent().findComponent("it1");
- String label = _labels[_getRandIndex()];
- uic.getAttributes().put("label", label);
- _addAttributeChange(uic, "label", label);
- }
-
- /**
- * Appends an objectImage child to the panelGroup in the underlying JSP document
- */
- public void appendChildToDocument(ActionEvent event)
- {
- UIComponent eventSource = event.getComponent();
- UIComponent uic = eventSource.findComponent("pg1");
-
- // only allow the image to be added once
- if (_findChildById(uic,"oi3") != null)
- return;
-
- FacesContext fc = FacesContext.getCurrentInstance();
-
- DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
-
- if (imageFragment != null)
- {
- DocumentChange change = new AddChildDocumentChange(imageFragment);
-
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
-
- apm.addDocumentChange(fc, uic, change);
- }
- }
-
- /**
- * Appends an objectImage child to the panelGroup.
- */
- public void appendChild(ActionEvent event)
- {
- UIComponent eventSource = event.getComponent();
- UIComponent uic = eventSource.findComponent("pg1");
- if (_findChildById(uic,"oi2") != null)
- return;
- FacesContext fc = FacesContext.getCurrentInstance();
-
- CoreObjectImage newChild =
- (CoreObjectImage) fc.getApplication().createComponent(
- "org.apache.myfaces.adf.CoreObjectImage");
- newChild.setId("oi2");
- newChild.setInlineStyle("height: 100px, width: 120px");
- newChild.setSource(
- "http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg");
- uic.getChildren().add(newChild);
-
- ComponentChange aca = new AddChildComponentChange(newChild);
-
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- apm.addComponentChange(fc, uic, aca);
- }
-
- /**
- * Adds a 'brandingAppContextual' facet to the panelGroup.
- */
- public void addFacet(ActionEvent event)
- {
- UIComponent eventSource = event.getComponent();
- UIComponent uic = eventSource.findComponent("pp1");
- FacesContext fc = FacesContext.getCurrentInstance();
- CoreOutputFormatted newFacetComponent =
- (CoreOutputFormatted) fc.getApplication().createComponent(
- "org.apache.myfaces.adf.CoreOutputFormatted");
- newFacetComponent.setStyleUsage("inContextBranding" );
- newFacetComponent.setValue(
- "Customer Company - Menlo Park");
- uic.getFacets().put("brandingAppContextual", newFacetComponent);
-
- ComponentChange afa = new SetFacetChildComponentChange("brandingAppContextual", newFacetComponent);
-
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- apm.addComponentChange(fc, uic, afa);
- }
-
- /**
- * Reverses the order of children of the panelGroup.
- */
- public void reorderChildren(ActionEvent event)
- {
- UIComponent uic = event.getComponent().findComponent("pg1");
- int numChildren = uic.getChildCount();
- if (numChildren == 0)
- return;
- List children = uic.getChildren();
- Collections.reverse(children);
- List reorderedChildIdList = new ArrayList();
- for (int i=0; i<children.size(); i++)
- {
- UIComponent child = (UIComponent) children.get(i);
- reorderedChildIdList.add(child.getId());
- }
-
- ComponentChange ra = new ReorderChildrenComponentChange(reorderedChildIdList);
-
- FacesContext fc = FacesContext.getCurrentInstance();
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- apm.addComponentChange(fc, uic, ra);
- }
-
- /**
- * Removes a pair of children, based on some characteristic of the
- * event source.
- */
- public void removeChildren(ActionEvent event)
- {
- UIComponent eventSource = event.getComponent();
- UIComponent uic = eventSource.findComponent("pg1");
- int numChildren = uic.getChildCount();
- if (numChildren == 0)
- return;
- String eventSourceId = eventSource.getId();
- if (eventSourceId.equals("cb2"))
- {
- _removeChild(uic, "sic1");
- _removeChild(uic, "cc1");
- }
- else if (eventSourceId.equals("cb3"))
- {
- _removeChild(uic, "cd1");
- _removeChild(uic, "sid1");
- }
- }
-
- /**
- * Removes one or more facets, based on some characteristic of the
- * event source.
- */
- public void removeFacets(ActionEvent event)
- {
- CoreCommandButton eventSource = (CoreCommandButton) event.getComponent();
- //pu: Anything until ":" in the button text represents the facet name/s
- String facetNameFromButtonText = (eventSource.getText().split(":"))[0];
- //pu: In case of the button that removes multiple facets, this is again
- // delimited by "_"
- String removableFacetNames[] = facetNameFromButtonText.split("_");
-
- //pu: Get the CorePanelPage components that has all the removable facets
- UIComponent uic = eventSource.findComponent("pp1");
- Map facets = uic.getFacets();
- if (facets.keySet().size() == 0)
- return;
-
- for (int i=0; i<removableFacetNames.length; i++)
- {
- if (facets.get(removableFacetNames[i]) != null)
- {
- facets.remove(removableFacetNames[i]);
- ComponentChange rfa = new RemoveFacetComponentChange(removableFacetNames[i]);
- FacesContext fc = FacesContext.getCurrentInstance();
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- apm.addComponentChange(fc, uic, rfa);
- }
- }
- }
-
- /**
- * Creates a DocumentFragment containing the parsed content
- * @param markUp JSP Document markup
- * @return DocumentFragment containing the parsed content
- */
- private static DocumentFragment _createDocumentFragment(
- String markUp)
- {
- // prepend XML declaration
- markUp = "<?xml version = '1.0' encoding = 'ISO-8859-1'?>" + markUp;
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(false);
-
- DocumentBuilder builder;
-
- try
- {
- builder = factory.newDocumentBuilder();
- }
- catch (ParserConfigurationException pce)
- {
- _LOG.log(Level.WARNING, "Unable to get XML Parser:", pce);
-
- return null;
- }
-
- try
- {
- // use a version explicitly with ISO-8859-1 instead
- byte[] markupBytes = markUp.getBytes();
- Document newDoc = builder.parse(new ByteArrayInputStream(markupBytes));
-
- DocumentFragment fragment = newDoc.createDocumentFragment();
-
- // add the document's root element to the fragment
- fragment.appendChild(newDoc.getDocumentElement());
-
- return fragment;
- }
- catch (SAXException se)
- {
- _LOG.log(Level.WARNING, "Unable to parse markup:" + markUp, se);
-
- return null;
- }
- catch (IOException ioe)
- {
- _LOG.log(Level.WARNING, "IO Problem with markup:" + markUp, ioe);
-
- return null;
- }
- }
-
- private static void _removeChild(UIComponent uic, String removableChildId)
- {
- UIComponent removableChild = _findChildById(uic, removableChildId);
- if (removableChild != null)
- {
- List children = uic.getChildren();
- children.remove(removableChild);
- ComponentChange rca = new RemoveChildComponentChange(removableChildId);
- FacesContext fc = FacesContext.getCurrentInstance();
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- apm.addComponentChange(fc, uic, rca);
- }
- }
-
- private static UIComponent _findChildById(UIComponent uic, String id)
- {
- int numChildren = uic.getChildCount();
- if (numChildren == 0)
- return null;
- List children = uic.getChildren();
- UIComponent child = null;
- for (int i=0; i<numChildren; i++)
- {
- child = (UIComponent) children.get(i);
- if (id.equals(child.getId()))
- return child;
- }
- return null;
- }
-
- private static void _addAttributeChange(
- UIComponent uic,
- String attribName,
- Object attribValue
- )
- {
- FacesContext fc = FacesContext.getCurrentInstance();
- ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
- ComponentChange aa = new AttributeComponentChange(attribName, attribValue);
- apm.addComponentChange(fc, uic, aa);
- }
-
- private static int _getRandIndex()
- {
- return (int) (Math.random()*10)/2;
- }
-
- private static final String _images[] =
- {"cobrand.gif","corporateBrand.gif","largeAd.gif","mediumAd.gif","new.gif"};
- private static final String _labels[] =
- {"Label One","Label Two","Label Three","Label Four","Label Five"};
- private static final String _texts[] =
- {"PanelBoxText One",
- "PanelBoxText Two",
- "PanelBoxText Three",
- "PanelBoxText Four",
- "PanelBoxText Five"};
-
- // markup to use for image added to document
- private static final String _IMAGE_MARK_UP =
- "<af:objectImage id='oi3' inlineStyle='height: 100px; width: 120px;' " +
- "source='http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg' " +
- "xmlns:af='http://myfaces.apache.org/adf/faces/EA17'/>";
-
- static private final Logger _LOG = Logger.getLogger(ChangeBean.class.getName());
+package org.apache.myfaces.adfdemo.change;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.myfaces.adf.change.AddChildComponentChange;
+import org.apache.myfaces.adf.change.AddChildDocumentChange;
+import org.apache.myfaces.adf.change.SetFacetChildComponentChange;
+import org.apache.myfaces.adf.change.AttributeComponentChange;
+import org.apache.myfaces.adf.change.ChangeManager;
+import org.apache.myfaces.adf.change.ComponentChange;
+import org.apache.myfaces.adf.change.DocumentChange;
+import org.apache.myfaces.adf.change.RemoveChildComponentChange;
+import org.apache.myfaces.adf.change.RemoveFacetComponentChange;
+import org.apache.myfaces.adf.change.ReorderChildrenComponentChange;
+import org.apache.myfaces.adf.component.core.nav.CoreCommandButton;
+
+import org.apache.myfaces.adf.component.core.output.CoreObjectImage;
+import org.apache.myfaces.adf.component.core.output.CoreOutputFormatted;
+import org.apache.myfaces.adf.context.AdfFacesContext;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+
+import org.xml.sax.SAXException;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Managed bean for Change persistence demos.
+ * @version $Name: $ ($Revision: adfrt/faces/adf-faces-demo/src/main/java/oracle/adfdemo/view/faces/change/ChangeBean.java#1 $) $Date: 16-aug-2005.15:12:29 $
+ */
+public class ChangeBean
+{
+ /**
+ * Picks up an image randomly from a list and changes it on the objectImage.
+ */
+ public void modifyObjectImage(ActionEvent event)
+ {
+ UIComponent uic = event.getComponent().findComponent("oi1");
+ String source = "/components/images/" + _images[_getRandIndex()];
+ uic.getAttributes().put("source", source);
+ _addAttributeChange(uic, "source", source);
+ }
+
+ /**
+ * Picks up a string randomly from a list and changes the text attribute value
+ * of the panelBox.
+ */
+ public void modifyPanelBox(ActionEvent event)
+ {
+ UIComponent uic = event.getComponent().findComponent("pb1");
+ String text = _texts[_getRandIndex()];
+ uic.getAttributes().put("text", text);
+ _addAttributeChange(uic, "text", text);
+ }
+
+ /**
+ * Modifies the sortable property of the column.
+ */
+ public void modifyColumn(ActionEvent event)
+ {
+ //=-=pu: 'uic1' gets null, while 'uic' gets valid component, maybe a bug ?.
+ //UIComponent uic1 = event.getComponent().findComponent("c1");
+ UIComponent uic2 = event.getComponent().findComponent("t1");
+ UIComponent uic = uic2.findComponent("c1");
+
+ Object sortableAttrib = uic.getAttributes().get("sortable");
+ Boolean isSortable =
+ (sortableAttrib == null)? Boolean.TRUE:(Boolean)sortableAttrib;
+ Boolean newSortableValue =
+ Boolean.TRUE.equals(isSortable)? Boolean.FALSE:Boolean.TRUE;
+ uic.getAttributes().put("sortable", newSortableValue);
+ _addAttributeChange(uic, "sortable", newSortableValue);
+ }
+
+ /**
+ * Picks up a string randomly from a list and changes the label attribute
+ * value of the inputText.
+ */
+ public void modifyInputText(ActionEvent event)
+ {
+ UIComponent uic = event.getComponent().findComponent("it1");
+ String label = _labels[_getRandIndex()];
+ uic.getAttributes().put("label", label);
+ _addAttributeChange(uic, "label", label);
+ }
+
+ /**
+ * Appends an objectImage child to the panelGroup in the underlying JSP document
+ */
+ public void appendChildToDocument(ActionEvent event)
+ {
+ UIComponent eventSource = event.getComponent();
+ UIComponent uic = eventSource.findComponent("pg1");
+
+ // only allow the image to be added once
+ if (_findChildById(uic,"oi3") != null)
+ return;
+
+ FacesContext fc = FacesContext.getCurrentInstance();
+
+ DocumentFragment imageFragment = _createDocumentFragment(_IMAGE_MARK_UP);
+
+ if (imageFragment != null)
+ {
+ DocumentChange change = new AddChildDocumentChange(imageFragment);
+
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+
+ apm.addDocumentChange(fc, uic, change);
+ }
+ }
+
+ /**
+ * Appends an objectImage child to the panelGroup.
+ */
+ public void appendChild(ActionEvent event)
+ {
+ UIComponent eventSource = event.getComponent();
+ UIComponent uic = eventSource.findComponent("pg1");
+ if (_findChildById(uic,"oi2") != null)
+ return;
+ FacesContext fc = FacesContext.getCurrentInstance();
+
+ CoreObjectImage newChild =
+ (CoreObjectImage) fc.getApplication().createComponent(
+ "org.apache.myfaces.adf.CoreObjectImage");
+ newChild.setId("oi2");
+ newChild.setInlineStyle("height: 100px, width: 120px");
+ newChild.setSource(
+ "http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg");
+ uic.getChildren().add(newChild);
+
+ ComponentChange aca = new AddChildComponentChange(newChild);
+
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ apm.addComponentChange(fc, uic, aca);
+ }
+
+ /**
+ * Adds a 'brandingAppContextual' facet to the panelGroup.
+ */
+ public void addFacet(ActionEvent event)
+ {
+ UIComponent eventSource = event.getComponent();
+ UIComponent uic = eventSource.findComponent("pp1");
+ FacesContext fc = FacesContext.getCurrentInstance();
+ CoreOutputFormatted newFacetComponent =
+ (CoreOutputFormatted) fc.getApplication().createComponent(
+ "org.apache.myfaces.adf.CoreOutputFormatted");
+ newFacetComponent.setStyleUsage("inContextBranding" );
+ newFacetComponent.setValue(
+ "Customer Company - Menlo Park");
+ uic.getFacets().put("brandingAppContextual", newFacetComponent);
+
+ ComponentChange afa = new SetFacetChildComponentChange("brandingAppContextual", newFacetComponent);
+
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ apm.addComponentChange(fc, uic, afa);
+ }
+
+ /**
+ * Reverses the order of children of the panelGroup.
+ */
+ public void reorderChildren(ActionEvent event)
+ {
+ UIComponent uic = event.getComponent().findComponent("pg1");
+ int numChildren = uic.getChildCount();
+ if (numChildren == 0)
+ return;
+ List children = uic.getChildren();
+ Collections.reverse(children);
+ List reorderedChildIdList = new ArrayList();
+ for (int i=0; i<children.size(); i++)
+ {
+ UIComponent child = (UIComponent) children.get(i);
+ reorderedChildIdList.add(child.getId());
+ }
+
+ ComponentChange ra = new ReorderChildrenComponentChange(reorderedChildIdList);
+
+ FacesContext fc = FacesContext.getCurrentInstance();
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ apm.addComponentChange(fc, uic, ra);
+ }
+
+ /**
+ * Removes a pair of children, based on some characteristic of the
+ * event source.
+ */
+ public void removeChildren(ActionEvent event)
+ {
+ UIComponent eventSource = event.getComponent();
+ UIComponent uic = eventSource.findComponent("pg1");
+ int numChildren = uic.getChildCount();
+ if (numChildren == 0)
+ return;
+ String eventSourceId = eventSource.getId();
+ if (eventSourceId.equals("cb2"))
+ {
+ _removeChild(uic, "sic1");
+ _removeChild(uic, "cc1");
+ }
+ else if (eventSourceId.equals("cb3"))
+ {
+ _removeChild(uic, "cd1");
+ _removeChild(uic, "sid1");
+ }
+ }
+
+ /**
+ * Removes one or more facets, based on some characteristic of the
+ * event source.
+ */
+ public void removeFacets(ActionEvent event)
+ {
+ CoreCommandButton eventSource = (CoreCommandButton) event.getComponent();
+ //pu: Anything until ":" in the button text represents the facet name/s
+ String facetNameFromButtonText = (eventSource.getText().split(":"))[0];
+ //pu: In case of the button that removes multiple facets, this is again
+ // delimited by "_"
+ String removableFacetNames[] = facetNameFromButtonText.split("_");
+
+ //pu: Get the CorePanelPage components that has all the removable facets
+ UIComponent uic = eventSource.findComponent("pp1");
+ Map facets = uic.getFacets();
+ if (facets.keySet().size() == 0)
+ return;
+
+ for (int i=0; i<removableFacetNames.length; i++)
+ {
+ if (facets.get(removableFacetNames[i]) != null)
+ {
+ facets.remove(removableFacetNames[i]);
+ ComponentChange rfa = new RemoveFacetComponentChange(removableFacetNames[i]);
+ FacesContext fc = FacesContext.getCurrentInstance();
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ apm.addComponentChange(fc, uic, rfa);
+ }
+ }
+ }
+
+ /**
+ * Creates a DocumentFragment containing the parsed content
+ * @param markUp JSP Document markup
+ * @return DocumentFragment containing the parsed content
+ */
+ private static DocumentFragment _createDocumentFragment(
+ String markUp)
+ {
+ // prepend XML declaration
+ markUp = "<?xml version = '1.0' encoding = 'ISO-8859-1'?>" + markUp;
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(false);
+
+ DocumentBuilder builder;
+
+ try
+ {
+ builder = factory.newDocumentBuilder();
+ }
+ catch (ParserConfigurationException pce)
+ {
+ _LOG.log(Level.WARNING, "Unable to get XML Parser:", pce);
+
+ return null;
+ }
+
+ try
+ {
+ // use a version explicitly with ISO-8859-1 instead
+ byte[] markupBytes = markUp.getBytes();
+ Document newDoc = builder.parse(new ByteArrayInputStream(markupBytes));
+
+ DocumentFragment fragment = newDoc.createDocumentFragment();
+
+ // add the document's root element to the fragment
+ fragment.appendChild(newDoc.getDocumentElement());
+
+ return fragment;
+ }
+ catch (SAXException se)
+ {
+ _LOG.log(Level.WARNING, "Unable to parse markup:" + markUp, se);
+
+ return null;
+ }
+ catch (IOException ioe)
+ {
+ _LOG.log(Level.WARNING, "IO Problem with markup:" + markUp, ioe);
+
+ return null;
+ }
+ }
+
+ private static void _removeChild(UIComponent uic, String removableChildId)
+ {
+ UIComponent removableChild = _findChildById(uic, removableChildId);
+ if (removableChild != null)
+ {
+ List children = uic.getChildren();
+ children.remove(removableChild);
+ ComponentChange rca = new RemoveChildComponentChange(removableChildId);
+ FacesContext fc = FacesContext.getCurrentInstance();
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ apm.addComponentChange(fc, uic, rca);
+ }
+ }
+
+ private static UIComponent _findChildById(UIComponent uic, String id)
+ {
+ int numChildren = uic.getChildCount();
+ if (numChildren == 0)
+ return null;
+ List children = uic.getChildren();
+ UIComponent child = null;
+ for (int i=0; i<numChildren; i++)
+ {
+ child = (UIComponent) children.get(i);
+ if (id.equals(child.getId()))
+ return child;
+ }
+ return null;
+ }
+
+ private static void _addAttributeChange(
+ UIComponent uic,
+ String attribName,
+ Object attribValue
+ )
+ {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ ChangeManager apm = AdfFacesContext.getCurrentInstance().getChangeManager();
+ ComponentChange aa = new AttributeComponentChange(attribName, attribValue);
+ apm.addComponentChange(fc, uic, aa);
+ }
+
+ private static int _getRandIndex()
+ {
+ return (int) (Math.random()*10)/2;
+ }
+
+ private static final String _images[] =
+ {"cobrand.gif","corporateBrand.gif","largeAd.gif","mediumAd.gif","new.gif"};
+ private static final String _labels[] =
+ {"Label One","Label Two","Label Three","Label Four","Label Five"};
+ private static final String _texts[] =
+ {"PanelBoxText One",
+ "PanelBoxText Two",
+ "PanelBoxText Three",
+ "PanelBoxText Four",
+ "PanelBoxText Five"};
+
+ // markup to use for image added to document
+ private static final String _IMAGE_MARK_UP =
+ "<af:objectImage id='oi3' inlineStyle='height: 100px; width: 120px;' " +
+ "source='http://homepage.mac.com/awiner/.Pictures/WindyHill/PaleSwallowtail.jpg' " +
+ "xmlns:af='http://myfaces.apache.org/adf/faces/EA17'/>";
+
+ static private final Logger _LOG = Logger.getLogger(ChangeBean.class.getName());
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/change/ChangeBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/CompositeTest.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/CompositeTest.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/CompositeTest.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/CompositeTest.java Mon Jul 24 22:27:24 2006
@@ -13,43 +13,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.composite;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-
-public class CompositeTest
-{
- public CompositeTest()
- {
- }
-
- public UIComponent getDateInput()
- {
- return _dateInput;
- }
-
- public void setDateInput(UIComponent dateInput)
- {
- _dateInput = dateInput;
- }
-
- private UIComponent _dateInput = new ForceRendererType();
-
- /**
- * Turns out there's no easy way to simply replace the renderer
- * for a control like UIInput; UIComponentTag will call setRendererType()
- * after consulting the "binding" attribute, overriding anything
- * done in either the getter or setter. So, here's a subclass
- * that forces the renderer type to a constant. The alternative
- * is writing a custom JSP tag to do the same, but then you
- * have to re-invent the wheel as far as the input tag goes.
- */
- static public class ForceRendererType extends UIInput
- {
- public String getRendererType()
- {
- return "org.apache.myfaces.adfdemo.DateField";
- }
- }
-}
+package org.apache.myfaces.adfdemo.composite;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+
+public class CompositeTest
+{
+ public CompositeTest()
+ {
+ }
+
+ public UIComponent getDateInput()
+ {
+ return _dateInput;
+ }
+
+ public void setDateInput(UIComponent dateInput)
+ {
+ _dateInput = dateInput;
+ }
+
+ private UIComponent _dateInput = new ForceRendererType();
+
+ /**
+ * Turns out there's no easy way to simply replace the renderer
+ * for a control like UIInput; UIComponentTag will call setRendererType()
+ * after consulting the "binding" attribute, overriding anything
+ * done in either the getter or setter. So, here's a subclass
+ * that forces the renderer type to a constant. The alternative
+ * is writing a custom JSP tag to do the same, but then you
+ * have to re-invent the wheel as far as the input tag goes.
+ */
+ static public class ForceRendererType extends UIInput
+ {
+ public String getRendererType()
+ {
+ return "org.apache.myfaces.adfdemo.DateField";
+ }
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/CompositeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateField.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateField.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateField.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateField.java Mon Jul 24 22:27:24 2006
@@ -13,225 +13,225 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.composite;
-
-import java.io.IOException;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.NumberConverter;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.validator.LongRangeValidator;
-
-import org.apache.myfaces.adf.component.UIXEditableValue;
-import org.apache.myfaces.adf.component.core.output.CoreOutputText;
-import org.apache.myfaces.adf.component.core.input.CoreInputText;
-
-/**
- * An experiment in building a composite component. Some basic
- * principles:
- * <ul>
- * <li> We're a NamingContainer, so our children won't show up in
- * findComponent() calls.
- * <li> The child components get re-created on each pass through
- * the system; this means seeing if they exist in both Apply Request
- * Values (<code>processDecodes</code>) and Render Response
- * (<code>encodeBegin()</code>), and marking the components
- * transient so they don't get saved.
- * <li> The model is the tricky part: instead of using real
- * <code>ValueBindings</code> on the children, I let them
- * use local values, and then manully transfer over their local values
- * into an overall "local value" during validate(). Unfortunately,
- * using ValueBindings to automate the transfer wouldn't quite work,
- * since the transfer wouldn't happen 'til Update Model, which is
- * too late to preserve the semantics of an editable value component in JSF.
- * <li>Apply Request Values and Update Model don't need to do anything special
- * for the children; they just run as needed.
- * </ul>
- * @author Adam Winer
- */
-public class DateField extends UIXEditableValue implements NamingContainer
-{
- public DateField()
- {
- super(null);
- }
-
-
- public void processDecodes(FacesContext context)
- {
- _addChildren(context);
- super.processDecodes(context);
- }
-
- public void validate(FacesContext context)
- {
- if (!_month.isValid() ||
- !_year.isValid() ||
- !_day.isValid())
- {
- setValid(false);
- return;
- }
-
- int year = ((Number) _year.getValue()).intValue();
- // We'll be 1970 - 2069. Good enough for a demo.
- if (year < 70)
- year += 100;
-
- int month = ((Number) _month.getValue()).intValue() - 1;
- int day = ((Number) _day.getValue()).intValue();
-
- Date oldValue = (Date) getValue();
- Date newValue = (Date) oldValue.clone();
- newValue.setYear(year);
- newValue.setMonth(month);
- newValue.setDate(day);
-
- //=-=AEW RUN VALIDATORS!
-
- // Invalid day given the month
- if (day != newValue.getDate())
- {
- int numberOfDaysInMonth = day - newValue.getDate();
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
- "Invalid date.",
- "This month only has " + numberOfDaysInMonth + " days!");
- setValid(false);
- context.addMessage(getClientId(context), message);
- }
- // Looks good
- else
- {
- setValid(true);
-
- // And if the value actually changed, store it and send a value change
- // event.
- if (!newValue.equals(oldValue))
- {
- setValue(newValue);
- queueEvent(new ValueChangeEvent(this, oldValue, newValue));
- }
- }
- }
-
- public void encodeBegin(FacesContext context) throws IOException
- {
- _addChildren(context);
- super.encodeBegin(context);
- }
-
- public void encodeChildren(FacesContext context) throws IOException
- {
- Iterator children = getChildren().iterator();
- while (children.hasNext())
- {
- UIComponent child = (UIComponent) children.next();
- assert(child.getChildCount() == 0);
- assert(child.getFacets().isEmpty());
- child.encodeBegin(context);
- child.encodeChildren(context);
- child.encodeEnd(context);
- }
- }
-
- public boolean getRendersChildren()
- {
- return true;
- }
-
- private void _addChildren(FacesContext context)
- {
- if (_month != null)
- return;
-
- List children = getChildren();
- children.clear();
-
- Date value = (Date) getValue();
-
- // A proper implementation would add children in the correct
- // order for the current locale
- _month = _createTwoDigitInput(context);
- _month.setId("month");
- _month.setShortDesc("Month");
- LongRangeValidator monthRange = _createLongRangeValidator(context);
- monthRange.setMinimum(1);
- monthRange.setMaximum(12);
- _month.addValidator(monthRange);
- if (value != null)
- _month.setValue(new Integer(value.getMonth() + 1));
-
- _day = _createTwoDigitInput(context);
- _day.setId("day");
- _day.setShortDesc("Day");
- LongRangeValidator dayRange = _createLongRangeValidator(context);
- dayRange.setMinimum(1);
- dayRange.setMaximum(31);
- _day.addValidator(dayRange);
- if (value != null)
- _day.setValue(new Integer(value.getDate()));
-
- _year = _createTwoDigitInput(context);
- _year.setId("year");
- _year.setShortDesc("Year");
- if (value != null)
- {
- int yearValue = value.getYear();
- if (yearValue >= 100)
- yearValue -= 100;
- _year.setValue(new Integer(yearValue));
- }
-
- children.add(_month);
- children.add(_createSeparator(context));
- children.add(_day);
- children.add(_createSeparator(context));
- children.add(_year);
- }
-
- private LongRangeValidator _createLongRangeValidator(FacesContext context)
- {
- return (LongRangeValidator)
- context.getApplication().createValidator(LongRangeValidator.VALIDATOR_ID);
- }
-
- private CoreInputText _createTwoDigitInput(FacesContext context)
- {
- CoreInputText input = new CoreInputText();
- input.setColumns(2);
- input.setMaximumLength(2);
- input.setTransient(true);
- input.setRequired(true);
- input.setSimple(true);
-
- NumberConverter converter = (NumberConverter)
- context.getApplication().createConverter(NumberConverter.CONVERTER_ID);
- converter.setIntegerOnly(true);
- converter.setMaxIntegerDigits(2);
- converter.setMinIntegerDigits(2);
- input.setConverter(converter);
-
- return input;
- }
-
- // A proper implementation would create a separator appropriate
- // to the current locale
- private CoreOutputText _createSeparator(FacesContext context)
- {
- CoreOutputText output = new CoreOutputText();
- output.setValue("/");
- output.setTransient(true);
- return output;
- }
-
- private transient CoreInputText _month;
- private transient CoreInputText _year;
- private transient CoreInputText _day;
-}
+package org.apache.myfaces.adfdemo.composite;
+
+import java.io.IOException;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.NumberConverter;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.validator.LongRangeValidator;
+
+import org.apache.myfaces.adf.component.UIXEditableValue;
+import org.apache.myfaces.adf.component.core.output.CoreOutputText;
+import org.apache.myfaces.adf.component.core.input.CoreInputText;
+
+/**
+ * An experiment in building a composite component. Some basic
+ * principles:
+ * <ul>
+ * <li> We're a NamingContainer, so our children won't show up in
+ * findComponent() calls.
+ * <li> The child components get re-created on each pass through
+ * the system; this means seeing if they exist in both Apply Request
+ * Values (<code>processDecodes</code>) and Render Response
+ * (<code>encodeBegin()</code>), and marking the components
+ * transient so they don't get saved.
+ * <li> The model is the tricky part: instead of using real
+ * <code>ValueBindings</code> on the children, I let them
+ * use local values, and then manully transfer over their local values
+ * into an overall "local value" during validate(). Unfortunately,
+ * using ValueBindings to automate the transfer wouldn't quite work,
+ * since the transfer wouldn't happen 'til Update Model, which is
+ * too late to preserve the semantics of an editable value component in JSF.
+ * <li>Apply Request Values and Update Model don't need to do anything special
+ * for the children; they just run as needed.
+ * </ul>
+ * @author Adam Winer
+ */
+public class DateField extends UIXEditableValue implements NamingContainer
+{
+ public DateField()
+ {
+ super(null);
+ }
+
+
+ public void processDecodes(FacesContext context)
+ {
+ _addChildren(context);
+ super.processDecodes(context);
+ }
+
+ public void validate(FacesContext context)
+ {
+ if (!_month.isValid() ||
+ !_year.isValid() ||
+ !_day.isValid())
+ {
+ setValid(false);
+ return;
+ }
+
+ int year = ((Number) _year.getValue()).intValue();
+ // We'll be 1970 - 2069. Good enough for a demo.
+ if (year < 70)
+ year += 100;
+
+ int month = ((Number) _month.getValue()).intValue() - 1;
+ int day = ((Number) _day.getValue()).intValue();
+
+ Date oldValue = (Date) getValue();
+ Date newValue = (Date) oldValue.clone();
+ newValue.setYear(year);
+ newValue.setMonth(month);
+ newValue.setDate(day);
+
+ //=-=AEW RUN VALIDATORS!
+
+ // Invalid day given the month
+ if (day != newValue.getDate())
+ {
+ int numberOfDaysInMonth = day - newValue.getDate();
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Invalid date.",
+ "This month only has " + numberOfDaysInMonth + " days!");
+ setValid(false);
+ context.addMessage(getClientId(context), message);
+ }
+ // Looks good
+ else
+ {
+ setValid(true);
+
+ // And if the value actually changed, store it and send a value change
+ // event.
+ if (!newValue.equals(oldValue))
+ {
+ setValue(newValue);
+ queueEvent(new ValueChangeEvent(this, oldValue, newValue));
+ }
+ }
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ _addChildren(context);
+ super.encodeBegin(context);
+ }
+
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ Iterator children = getChildren().iterator();
+ while (children.hasNext())
+ {
+ UIComponent child = (UIComponent) children.next();
+ assert(child.getChildCount() == 0);
+ assert(child.getFacets().isEmpty());
+ child.encodeBegin(context);
+ child.encodeChildren(context);
+ child.encodeEnd(context);
+ }
+ }
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ private void _addChildren(FacesContext context)
+ {
+ if (_month != null)
+ return;
+
+ List children = getChildren();
+ children.clear();
+
+ Date value = (Date) getValue();
+
+ // A proper implementation would add children in the correct
+ // order for the current locale
+ _month = _createTwoDigitInput(context);
+ _month.setId("month");
+ _month.setShortDesc("Month");
+ LongRangeValidator monthRange = _createLongRangeValidator(context);
+ monthRange.setMinimum(1);
+ monthRange.setMaximum(12);
+ _month.addValidator(monthRange);
+ if (value != null)
+ _month.setValue(new Integer(value.getMonth() + 1));
+
+ _day = _createTwoDigitInput(context);
+ _day.setId("day");
+ _day.setShortDesc("Day");
+ LongRangeValidator dayRange = _createLongRangeValidator(context);
+ dayRange.setMinimum(1);
+ dayRange.setMaximum(31);
+ _day.addValidator(dayRange);
+ if (value != null)
+ _day.setValue(new Integer(value.getDate()));
+
+ _year = _createTwoDigitInput(context);
+ _year.setId("year");
+ _year.setShortDesc("Year");
+ if (value != null)
+ {
+ int yearValue = value.getYear();
+ if (yearValue >= 100)
+ yearValue -= 100;
+ _year.setValue(new Integer(yearValue));
+ }
+
+ children.add(_month);
+ children.add(_createSeparator(context));
+ children.add(_day);
+ children.add(_createSeparator(context));
+ children.add(_year);
+ }
+
+ private LongRangeValidator _createLongRangeValidator(FacesContext context)
+ {
+ return (LongRangeValidator)
+ context.getApplication().createValidator(LongRangeValidator.VALIDATOR_ID);
+ }
+
+ private CoreInputText _createTwoDigitInput(FacesContext context)
+ {
+ CoreInputText input = new CoreInputText();
+ input.setColumns(2);
+ input.setMaximumLength(2);
+ input.setTransient(true);
+ input.setRequired(true);
+ input.setSimple(true);
+
+ NumberConverter converter = (NumberConverter)
+ context.getApplication().createConverter(NumberConverter.CONVERTER_ID);
+ converter.setIntegerOnly(true);
+ converter.setMaxIntegerDigits(2);
+ converter.setMinIntegerDigits(2);
+ input.setConverter(converter);
+
+ return input;
+ }
+
+ // A proper implementation would create a separator appropriate
+ // to the current locale
+ private CoreOutputText _createSeparator(FacesContext context)
+ {
+ CoreOutputText output = new CoreOutputText();
+ output.setValue("/");
+ output.setTransient(true);
+ return output;
+ }
+
+ private transient CoreInputText _month;
+ private transient CoreInputText _year;
+ private transient CoreInputText _day;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateField.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldAsRenderer.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldAsRenderer.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldAsRenderer.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldAsRenderer.java Mon Jul 24 22:27:24 2006
@@ -13,225 +13,225 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.composite;
-
-import java.io.IOException;
-
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.NumberConverter;
-import javax.faces.render.Renderer;
-import javax.faces.validator.LongRangeValidator;
-
-import org.apache.myfaces.adf.component.core.input.CoreInputText;
-
-/**
- * An experiment in building a renderer that uses a composite
- * component strategy to render. Some basic principles:
- * <ul>
- * <li> The child components get re-created on each pass through
- * the system; this means seeing if they exist in both Apply Request
- * Values (<code>decode()</code>) and Render Response
- * (<code>encodeBegin()</code>), and marking the components
- * transient so they don't get saved.
- * <li> The model is the tricky part: instead of using real
- * <code>ValueBindings</code> on the children, I let them
- * use local values, and then manully transfer over their local values
- * into an overall "local value" during validate(). Unfortunately,
- * using ValueBindings to automate the transfer wouldn't quite work,
- * since the transfer wouldn't happen 'til Update Model, which is
- * too late to preserve the semantics of an editable value component in JSF.
- * </ul>
- * @author Adam Winer
- */
-public class DateFieldAsRenderer extends Renderer
-{
- public void decode(FacesContext context, UIComponent component)
- {
- _addChildren(context, component);
-
- Map attrs = component.getAttributes();
- if (Boolean.TRUE.equals(attrs.get("readOnly")) ||
- Boolean.TRUE.equals(attrs.get("disabled")))
- return;
-
- // Just clue in component that we have been "submitted" so
- // that it doesn't short-circuit anything
- EditableValueHolder evh = (EditableValueHolder) component;
- evh.setSubmittedValue(Boolean.TRUE);
-
- // Because these components weren't around during processDecodes(),
- // they didn't get decoded. So, run that now.
- component.getFacet("month").processDecodes(context);
- component.getFacet("year").processDecodes(context);
- component.getFacet("day").processDecodes(context);
- }
-
- public Object getConvertedValue(
- FacesContext context,
- UIComponent component,
- Object submittedValue)
- {
- EditableValueHolder monthComp = (EditableValueHolder) component.getFacet("month");
- EditableValueHolder yearComp = (EditableValueHolder) component.getFacet("year");
- EditableValueHolder dayComp = (EditableValueHolder) component.getFacet("day");
-
- if (!monthComp.isValid() ||
- !yearComp.isValid() ||
- !dayComp.isValid())
- {
- // =-=AEW What to do????????
- //setValid(false);
- return null;
- }
-
- int year = ((Number) yearComp.getValue()).intValue();
- // We'll be 1970 - 2069. Good enough for a demo.
- if (year < 70)
- year += 100;
-
- int month = ((Number) monthComp.getValue()).intValue() - 1;
- int day = ((Number) dayComp.getValue()).intValue();
-
- Date oldValue = (Date) ((EditableValueHolder) component).getValue();
- Date newValue = (Date) oldValue.clone();
- newValue.setYear(year);
- newValue.setMonth(month);
- newValue.setDate(day);
-
- // Invalid day given the month
- if (day != newValue.getDate())
- {
- int numberOfDaysInMonth = day - newValue.getDate();
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
- "Invalid date.",
- "This month only has " + numberOfDaysInMonth + " days!");
- throw new ConverterException(message);
- }
-
- return newValue;
- }
-
- public void encodeBegin(FacesContext context,
- UIComponent component) throws IOException
- {
- _addChildren(context, component);
- }
-
- public void encodeChildren(FacesContext context,
- UIComponent component) throws IOException
- {
- ResponseWriter out = context.getResponseWriter();
-
- UIComponent month = component.getFacet("month");
- month.encodeBegin(context);
- month.encodeChildren(context);
- month.encodeEnd(context);
-
- out.writeText("\u00a0/\u00a0", null);
-
- UIComponent day = component.getFacet("day");
- day.encodeBegin(context);
- day.encodeChildren(context);
- day.encodeEnd(context);
-
- out.writeText("\u00a0/\u00a0", null);
-
- UIComponent year = component.getFacet("year");
- year.encodeBegin(context);
- year.encodeChildren(context);
- year.encodeEnd(context);
- }
-
- public boolean getRendersChildren()
- {
- return true;
- }
-
- private void _addChildren(FacesContext context, UIComponent component)
- {
- // If the components are already there, bail.
- if (component.getFacet("month") != null)
- return;
-
- String id = component.getId();
- if (id == null)
- {
- id = context.getViewRoot().createUniqueId();
- component.setId(id);
- }
-
- Map facets = component.getFacets();
- facets.clear();
-
- Date value = (Date) ((EditableValueHolder) component).getValue();
-
- CoreInputText month = _createTwoDigitInput(context);
- month.setShortDesc("Month");
- month.setId(id + "_month");
-
- LongRangeValidator monthRange = _createLongRangeValidator(context);
- monthRange.setMinimum(1);
- monthRange.setMaximum(12);
- month.addValidator(monthRange);
- if (value != null)
- month.setValue(new Integer(value.getMonth() + 1));
- facets.put("month", month);
-
- CoreInputText day = _createTwoDigitInput(context);
- day.setShortDesc("Day");
- day.setId(id + "_day");
- LongRangeValidator dayRange = _createLongRangeValidator(context);
- dayRange.setMinimum(1);
- dayRange.setMaximum(31);
- day.addValidator(dayRange);
- if (value != null)
- day.setValue(new Integer(value.getDate()));
- facets.put("day", day);
-
- CoreInputText year = _createTwoDigitInput(context);
- year.setShortDesc("Year");
- year.setId(id + "_year");
- if (value != null)
- {
- int yearValue = value.getYear();
- if (yearValue >= 100)
- yearValue -= 100;
- year.setValue(new Integer(yearValue));
- }
-
- facets.put("year", year);
- }
-
- private LongRangeValidator _createLongRangeValidator(FacesContext context)
- {
- return (LongRangeValidator)
- context.getApplication().createValidator(LongRangeValidator.VALIDATOR_ID);
- }
-
- private CoreInputText _createTwoDigitInput(FacesContext context)
- {
- CoreInputText input = new CoreInputText();
- input.setColumns(2);
- input.setMaximumLength(2);
- input.setTransient(true);
- input.setRequired(true);
- input.setSimple(true);
-
- NumberConverter converter = (NumberConverter)
- context.getApplication().createConverter(NumberConverter.CONVERTER_ID);
- converter.setIntegerOnly(true);
- converter.setMaxIntegerDigits(2);
- converter.setMinIntegerDigits(2);
- input.setConverter(converter);
-
- return input;
- }
-}
+package org.apache.myfaces.adfdemo.composite;
+
+import java.io.IOException;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.NumberConverter;
+import javax.faces.render.Renderer;
+import javax.faces.validator.LongRangeValidator;
+
+import org.apache.myfaces.adf.component.core.input.CoreInputText;
+
+/**
+ * An experiment in building a renderer that uses a composite
+ * component strategy to render. Some basic principles:
+ * <ul>
+ * <li> The child components get re-created on each pass through
+ * the system; this means seeing if they exist in both Apply Request
+ * Values (<code>decode()</code>) and Render Response
+ * (<code>encodeBegin()</code>), and marking the components
+ * transient so they don't get saved.
+ * <li> The model is the tricky part: instead of using real
+ * <code>ValueBindings</code> on the children, I let them
+ * use local values, and then manully transfer over their local values
+ * into an overall "local value" during validate(). Unfortunately,
+ * using ValueBindings to automate the transfer wouldn't quite work,
+ * since the transfer wouldn't happen 'til Update Model, which is
+ * too late to preserve the semantics of an editable value component in JSF.
+ * </ul>
+ * @author Adam Winer
+ */
+public class DateFieldAsRenderer extends Renderer
+{
+ public void decode(FacesContext context, UIComponent component)
+ {
+ _addChildren(context, component);
+
+ Map attrs = component.getAttributes();
+ if (Boolean.TRUE.equals(attrs.get("readOnly")) ||
+ Boolean.TRUE.equals(attrs.get("disabled")))
+ return;
+
+ // Just clue in component that we have been "submitted" so
+ // that it doesn't short-circuit anything
+ EditableValueHolder evh = (EditableValueHolder) component;
+ evh.setSubmittedValue(Boolean.TRUE);
+
+ // Because these components weren't around during processDecodes(),
+ // they didn't get decoded. So, run that now.
+ component.getFacet("month").processDecodes(context);
+ component.getFacet("year").processDecodes(context);
+ component.getFacet("day").processDecodes(context);
+ }
+
+ public Object getConvertedValue(
+ FacesContext context,
+ UIComponent component,
+ Object submittedValue)
+ {
+ EditableValueHolder monthComp = (EditableValueHolder) component.getFacet("month");
+ EditableValueHolder yearComp = (EditableValueHolder) component.getFacet("year");
+ EditableValueHolder dayComp = (EditableValueHolder) component.getFacet("day");
+
+ if (!monthComp.isValid() ||
+ !yearComp.isValid() ||
+ !dayComp.isValid())
+ {
+ // =-=AEW What to do????????
+ //setValid(false);
+ return null;
+ }
+
+ int year = ((Number) yearComp.getValue()).intValue();
+ // We'll be 1970 - 2069. Good enough for a demo.
+ if (year < 70)
+ year += 100;
+
+ int month = ((Number) monthComp.getValue()).intValue() - 1;
+ int day = ((Number) dayComp.getValue()).intValue();
+
+ Date oldValue = (Date) ((EditableValueHolder) component).getValue();
+ Date newValue = (Date) oldValue.clone();
+ newValue.setYear(year);
+ newValue.setMonth(month);
+ newValue.setDate(day);
+
+ // Invalid day given the month
+ if (day != newValue.getDate())
+ {
+ int numberOfDaysInMonth = day - newValue.getDate();
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "Invalid date.",
+ "This month only has " + numberOfDaysInMonth + " days!");
+ throw new ConverterException(message);
+ }
+
+ return newValue;
+ }
+
+ public void encodeBegin(FacesContext context,
+ UIComponent component) throws IOException
+ {
+ _addChildren(context, component);
+ }
+
+ public void encodeChildren(FacesContext context,
+ UIComponent component) throws IOException
+ {
+ ResponseWriter out = context.getResponseWriter();
+
+ UIComponent month = component.getFacet("month");
+ month.encodeBegin(context);
+ month.encodeChildren(context);
+ month.encodeEnd(context);
+
+ out.writeText("\u00a0/\u00a0", null);
+
+ UIComponent day = component.getFacet("day");
+ day.encodeBegin(context);
+ day.encodeChildren(context);
+ day.encodeEnd(context);
+
+ out.writeText("\u00a0/\u00a0", null);
+
+ UIComponent year = component.getFacet("year");
+ year.encodeBegin(context);
+ year.encodeChildren(context);
+ year.encodeEnd(context);
+ }
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ private void _addChildren(FacesContext context, UIComponent component)
+ {
+ // If the components are already there, bail.
+ if (component.getFacet("month") != null)
+ return;
+
+ String id = component.getId();
+ if (id == null)
+ {
+ id = context.getViewRoot().createUniqueId();
+ component.setId(id);
+ }
+
+ Map facets = component.getFacets();
+ facets.clear();
+
+ Date value = (Date) ((EditableValueHolder) component).getValue();
+
+ CoreInputText month = _createTwoDigitInput(context);
+ month.setShortDesc("Month");
+ month.setId(id + "_month");
+
+ LongRangeValidator monthRange = _createLongRangeValidator(context);
+ monthRange.setMinimum(1);
+ monthRange.setMaximum(12);
+ month.addValidator(monthRange);
+ if (value != null)
+ month.setValue(new Integer(value.getMonth() + 1));
+ facets.put("month", month);
+
+ CoreInputText day = _createTwoDigitInput(context);
+ day.setShortDesc("Day");
+ day.setId(id + "_day");
+ LongRangeValidator dayRange = _createLongRangeValidator(context);
+ dayRange.setMinimum(1);
+ dayRange.setMaximum(31);
+ day.addValidator(dayRange);
+ if (value != null)
+ day.setValue(new Integer(value.getDate()));
+ facets.put("day", day);
+
+ CoreInputText year = _createTwoDigitInput(context);
+ year.setShortDesc("Year");
+ year.setId(id + "_year");
+ if (value != null)
+ {
+ int yearValue = value.getYear();
+ if (yearValue >= 100)
+ yearValue -= 100;
+ year.setValue(new Integer(yearValue));
+ }
+
+ facets.put("year", year);
+ }
+
+ private LongRangeValidator _createLongRangeValidator(FacesContext context)
+ {
+ return (LongRangeValidator)
+ context.getApplication().createValidator(LongRangeValidator.VALIDATOR_ID);
+ }
+
+ private CoreInputText _createTwoDigitInput(FacesContext context)
+ {
+ CoreInputText input = new CoreInputText();
+ input.setColumns(2);
+ input.setMaximumLength(2);
+ input.setTransient(true);
+ input.setRequired(true);
+ input.setSimple(true);
+
+ NumberConverter converter = (NumberConverter)
+ context.getApplication().createConverter(NumberConverter.CONVERTER_ID);
+ converter.setIntegerOnly(true);
+ converter.setMaxIntegerDigits(2);
+ converter.setMinIntegerDigits(2);
+ input.setConverter(converter);
+
+ return input;
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldAsRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldTag.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldTag.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldTag.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldTag.java Mon Jul 24 22:27:24 2006
@@ -13,25 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.composite;
-
-import org.apache.myfaces.adfinternal.taglib.UIXEditableValueTag;
-
-
-/**
- * NOTE: a clients may not extend UIXEditableValueTag (or
- * any other tag classes), as these are not part of the public
- * API (note the package); I'm doing it for expedience here.
- */
-public class DateFieldTag extends UIXEditableValueTag
-{
- public String getComponentType()
- {
- return "org.apache.myfaces.adfdemo.DateField";
- }
-
- public String getRendererType()
- {
- return null;
- }
-}
+package org.apache.myfaces.adfdemo.composite;
+
+import org.apache.myfaces.adfinternal.taglib.UIXEditableValueTag;
+
+
+/**
+ * NOTE: a clients may not extend UIXEditableValueTag (or
+ * any other tag classes), as these are not part of the public
+ * API (note the package); I'm doing it for expedience here.
+ */
+public class DateFieldTag extends UIXEditableValueTag
+{
+ public String getComponentType()
+ {
+ return "org.apache.myfaces.adfdemo.DateField";
+ }
+
+ public String getRendererType()
+ {
+ return null;
+ }
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/composite/DateFieldTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/ChooseIntegerBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/ChooseIntegerBean.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/ChooseIntegerBean.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/ChooseIntegerBean.java Mon Jul 24 22:27:24 2006
@@ -13,42 +13,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.dialog;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.adf.context.AdfFacesContext;
-import org.apache.myfaces.adf.event.ReturnEvent;
-
-public class ChooseIntegerBean
-{
- public Integer getValue1()
- {
- return _value1;
- }
-
- public void setValue1(Integer value1)
- {
- _value1 = value1;
- }
-
- public Integer getValue2()
- {
- return _value2;
- }
-
- public void setValue2(Integer value2)
- {
- _value2 = value2;
- }
-
- public void sayHello(ReturnEvent event)
- {
- FacesMessage message = new FacesMessage("Hello!");
- FacesContext.getCurrentInstance().addMessage(null, message);
- }
-
- private Integer _value1;
- private Integer _value2;
-}
+package org.apache.myfaces.adfdemo.dialog;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.adf.context.AdfFacesContext;
+import org.apache.myfaces.adf.event.ReturnEvent;
+
+public class ChooseIntegerBean
+{
+ public Integer getValue1()
+ {
+ return _value1;
+ }
+
+ public void setValue1(Integer value1)
+ {
+ _value1 = value1;
+ }
+
+ public Integer getValue2()
+ {
+ return _value2;
+ }
+
+ public void setValue2(Integer value2)
+ {
+ _value2 = value2;
+ }
+
+ public void sayHello(ReturnEvent event)
+ {
+ FacesMessage message = new FacesMessage("Hello!");
+ FacesContext.getCurrentInstance().addMessage(null, message);
+ }
+
+ private Integer _value1;
+ private Integer _value2;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/ChooseIntegerBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/LaunchDialogBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/LaunchDialogBean.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/LaunchDialogBean.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/LaunchDialogBean.java Mon Jul 24 22:27:24 2006
@@ -13,114 +13,114 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.dialog;
-
-import java.util.Date;
-import java.util.Map;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.adf.component.UIXInput;
-import org.apache.myfaces.adf.context.AdfFacesContext;
-import org.apache.myfaces.adf.event.ReturnEvent;
-import org.apache.myfaces.adf.event.LaunchEvent;
-import org.apache.myfaces.adf.event.PollEvent;
-
-public class LaunchDialogBean
-{
- public UIXInput getInput()
- {
- return _input;
- }
-
- public void setInput(UIXInput input)
- {
- _input = input;
- }
-
- public void addParameter(LaunchEvent event)
- {
- // Pass an integer into the dialog. Some automatic
- // coercion would really help here (coming in JSF 1.2?)
- Object value = getInput().getValue();
- if (value != null)
- {
- try
- {
- Integer i = Integer.valueOf(value.toString());
- event.getDialogParameters().put("value", i);
- }
- catch (Exception e)
- {
- }
- }
- }
-
- public String doLaunch()
- {
- AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
- Map process = afContext.getPageFlowScope();
- process.put("lastLaunch", new Date());
-
- return "dialog:chooseInteger";
- }
-
- public void returned(ReturnEvent event)
- {
- if (event.getReturnValue() != null)
- {
- getInput().setSubmittedValue(null);
- getInput().setValue(event.getReturnValue());
-
- AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
- afContext.addPartialTarget(getInput());
-
- FacesContext context = FacesContext.getCurrentInstance();
- UIViewRoot root = context.getApplication().getViewHandler().createView(
- context, "/demos/successDialog.jspx");
- // Launch a new, success dialog with a different width and height;
- // this shows how to do so by queueing a LaunchEvent.
- LaunchEvent launchEvent = new LaunchEvent(event.getComponent(), root);
- launchEvent.getWindowProperties().put("width", "200");
- launchEvent.getWindowProperties().put("height", "100");
- launchEvent.queue();
- }
- }
-
-
- public void poll(PollEvent event)
- {
- FacesContext context = FacesContext.getCurrentInstance();
- UIViewRoot root = context.getApplication().getViewHandler().createView(
- context, "/demos/simpleDialog.jspx");
-
- // Launch a dialog with a call to AdfFacesContext
- AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
- afContext.launchDialog(root, null, event.getComponent(), true, null);
- // Stop the poll from running
- event.getComponent().setRendered(false);
- }
-
- public UIXInput getTableInput()
- {
- return _tableInput;
- }
-
- public void setTableInput(UIXInput tableInput)
- {
- _tableInput = tableInput;
- }
-
- public void tableReturned(ReturnEvent event)
- {
- if (event.getReturnValue() != null)
- {
- getTableInput().setValue(event.getReturnValue());
- AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
- afContext.addPartialTarget(getTableInput());
- }
- }
-
- private UIXInput _input;
- private UIXInput _tableInput;
-}
+package org.apache.myfaces.adfdemo.dialog;
+
+import java.util.Date;
+import java.util.Map;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.adf.component.UIXInput;
+import org.apache.myfaces.adf.context.AdfFacesContext;
+import org.apache.myfaces.adf.event.ReturnEvent;
+import org.apache.myfaces.adf.event.LaunchEvent;
+import org.apache.myfaces.adf.event.PollEvent;
+
+public class LaunchDialogBean
+{
+ public UIXInput getInput()
+ {
+ return _input;
+ }
+
+ public void setInput(UIXInput input)
+ {
+ _input = input;
+ }
+
+ public void addParameter(LaunchEvent event)
+ {
+ // Pass an integer into the dialog. Some automatic
+ // coercion would really help here (coming in JSF 1.2?)
+ Object value = getInput().getValue();
+ if (value != null)
+ {
+ try
+ {
+ Integer i = Integer.valueOf(value.toString());
+ event.getDialogParameters().put("value", i);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ public String doLaunch()
+ {
+ AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
+ Map process = afContext.getPageFlowScope();
+ process.put("lastLaunch", new Date());
+
+ return "dialog:chooseInteger";
+ }
+
+ public void returned(ReturnEvent event)
+ {
+ if (event.getReturnValue() != null)
+ {
+ getInput().setSubmittedValue(null);
+ getInput().setValue(event.getReturnValue());
+
+ AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
+ afContext.addPartialTarget(getInput());
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIViewRoot root = context.getApplication().getViewHandler().createView(
+ context, "/demos/successDialog.jspx");
+ // Launch a new, success dialog with a different width and height;
+ // this shows how to do so by queueing a LaunchEvent.
+ LaunchEvent launchEvent = new LaunchEvent(event.getComponent(), root);
+ launchEvent.getWindowProperties().put("width", "200");
+ launchEvent.getWindowProperties().put("height", "100");
+ launchEvent.queue();
+ }
+ }
+
+
+ public void poll(PollEvent event)
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIViewRoot root = context.getApplication().getViewHandler().createView(
+ context, "/demos/simpleDialog.jspx");
+
+ // Launch a dialog with a call to AdfFacesContext
+ AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
+ afContext.launchDialog(root, null, event.getComponent(), true, null);
+ // Stop the poll from running
+ event.getComponent().setRendered(false);
+ }
+
+ public UIXInput getTableInput()
+ {
+ return _tableInput;
+ }
+
+ public void setTableInput(UIXInput tableInput)
+ {
+ _tableInput = tableInput;
+ }
+
+ public void tableReturned(ReturnEvent event)
+ {
+ if (event.getReturnValue() != null)
+ {
+ getTableInput().setValue(event.getReturnValue());
+ AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
+ afContext.addPartialTarget(getTableInput());
+ }
+ }
+
+ private UIXInput _input;
+ private UIXInput _tableInput;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/LaunchDialogBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/PeriodicDialogBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/PeriodicDialogBean.java?rev=425291&r1=425290&r2=425291&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/PeriodicDialogBean.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/PeriodicDialogBean.java Mon Jul 24 22:27:24 2006
@@ -13,52 +13,52 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.myfaces.adfdemo.dialog;
-
-import java.util.Iterator;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.adf.component.UIXTable;
-import org.apache.myfaces.adf.context.AdfFacesContext;
-
-public class PeriodicDialogBean
-{
- public UIXTable getTable()
- {
- return _table;
- }
-
- public void setTable(UIXTable table)
- {
- _table = table;
- }
-
- public String cancel()
- {
- AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
- return null;
- }
-
- public String select()
- {
- FacesContext context = FacesContext.getCurrentInstance();
- // The tableSelectOne is marked as required; so there'd better
- // be a selected row - an exception will result here if there
- // isn't. Is there some better code?
- Iterator iterator = _table.getSelectedRowKeys().iterator();
- String rowKey = (String) iterator.next();
- Object oldRowKey = _table.getRowKey();
- _table.setRowKey(rowKey);
- ValueBinding binding = context.getApplication().
- createValueBinding("#{row.symbol}");
- Object value = binding.getValue(context);
- AdfFacesContext.getCurrentInstance().returnFromDialog(value, null);
- _table.setRowKey(oldRowKey);
-
- return null;
- }
-
- private UIXTable _table;
-}
+package org.apache.myfaces.adfdemo.dialog;
+
+import java.util.Iterator;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.adf.component.UIXTable;
+import org.apache.myfaces.adf.context.AdfFacesContext;
+
+public class PeriodicDialogBean
+{
+ public UIXTable getTable()
+ {
+ return _table;
+ }
+
+ public void setTable(UIXTable table)
+ {
+ _table = table;
+ }
+
+ public String cancel()
+ {
+ AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
+ return null;
+ }
+
+ public String select()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ // The tableSelectOne is marked as required; so there'd better
+ // be a selected row - an exception will result here if there
+ // isn't. Is there some better code?
+ Iterator iterator = _table.getSelectedRowKeys().iterator();
+ String rowKey = (String) iterator.next();
+ Object oldRowKey = _table.getRowKey();
+ _table.setRowKey(rowKey);
+ ValueBinding binding = context.getApplication().
+ createValueBinding("#{row.symbol}");
+ Object value = binding.getValue(context);
+ AdfFacesContext.getCurrentInstance().returnFromDialog(value, null);
+ _table.setRowKey(oldRowKey);
+
+ return null;
+ }
+
+ private UIXTable _table;
+}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/adfdemo/dialog/PeriodicDialogBean.java
------------------------------------------------------------------------------
svn:eol-style = native