001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: */
019:
020: package de.skelexamples;
021:
022: import de.schlund.pfixcore.generator.IHandler;
023: import de.schlund.pfixcore.generator.IWrapper;
024: import de.schlund.pfixcore.workflow.Context;
025: import de.schlund.pfixcore.workflow.ContextResourceManager;
026:
027: /**
028: * A class handling the request sent by the action of the form. This class is
029: * similiar to a Struts Action (inherited from
030: * org.apache.struts.action.Action). The Struts method perform is similiar to
031: * handleSubmittedData.
032: *
033: * @author <a href="mailto:rapude@schlund.de">Ralf Rapude </a>
034: * @version $Id: DemoTextHandler.java 2536 2006-02-27 16:13:42Z uplatze $
035: */
036: public class DemoTextHandler implements IHandler {
037:
038: /*
039: * (non-Javadoc)
040: *
041: * @see de.schlund.pfixcore.generator.IHandler#handleSubmittedData(de.schlund.pfixcore.workflow.Context,
042: * de.schlund.pfixcore.generator.IWrapper)
043: */
044: public void handleSubmittedData(Context context, IWrapper wrapper)
045: throws Exception {
046: ContextResourceManager crm = context
047: .getContextResourceManager();
048: ContextDemoText cdemotxt = (ContextDemoText) crm
049: .getResource("de.skelexamples.ContextDemoText");
050: DemoText txtwrp = (DemoText) wrapper;
051: String txt = txtwrp.getDemoText();
052:
053: System.out.println(" ====> Get DemoText from the form: " + txt);
054: cdemotxt.setDemoText(txt);
055: }
056:
057: /**
058: * Setting the text for the form by asking the ContextResource for the
059: * content. Afterwards the IWrappers setter is called
060: *
061: * @see de.schlund.pfixcore.generator.IHandler#retrieveCurrentStatus(de.schlund.pfixcore.workflow.Context,
062: * de.schlund.pfixcore.generator.IWrapper)
063: */
064: public void retrieveCurrentStatus(Context context, IWrapper wrapper)
065: throws Exception {
066:
067: ContextResourceManager crm = context
068: .getContextResourceManager();
069: ContextDemoText cdemotxt = (ContextDemoText) crm
070: .getResource("de.skelexamples.ContextDemoText");
071: DemoText txtwrp = (DemoText) wrapper;
072: String txt = cdemotxt.getDemoText();
073:
074: if (txt != null) {
075: System.out.println(" ====> Set DemoText for the form: "
076: + txt);
077: txtwrp.setDemoText(txt);
078: }
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see de.schlund.pfixcore.generator.IHandler#prerequisitesMet(de.schlund.pfixcore.workflow.Context)
085: */
086: public boolean prerequisitesMet(Context context) throws Exception {
087: return true;
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see de.schlund.pfixcore.generator.IHandler#isActive(de.schlund.pfixcore.workflow.Context)
094: */
095: public boolean isActive(Context context) throws Exception {
096: return true;
097: }
098:
099: /*
100: * (non-Javadoc)
101: *
102: * @see de.schlund.pfixcore.generator.IHandler#needsData(de.schlund.pfixcore.workflow.Context)
103: */
104: public boolean needsData(Context context) throws Exception {
105: return true;
106: }
107: }
|