/*
* This software and supporting documentation were developed by
*
* Siemens Corporate Technology
* Competence Center Knowledge Management and Business Transformation
* D-81730 Munich, Germany
*
* Authors (representing a really great team ;-) )
* Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
* This software is Open Source under GNU General Public License (GPL).
* Read the text of this license in LICENSE.TXT
* or look at www.opensource.org/licenses/
*
* Once more we emphasize, that:
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, WITHOUT ANY WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/
package KFM.GUI.Templates;
import KFM.Exceptions.ProgrammerException;
import KFM.Language;
import java.io.*;
public class TemplateHandler
{
protected KfmTemplate templ;
protected Language language;
protected boolean isDebug = false;
public TemplateHandler(
/* TemplateObserver observer,*/
String theDir,
String theNamePrefix,
String ddefaultStylesheet,
String ffooterUrl)
{
templ = new KfmTemplate(theDir, theNamePrefix, ddefaultStylesheet, ffooterUrl);
}
public void startWithLanguage(Language lang)
{
templ.startWithLanguage(lang);
language = lang;
}
/**
*@param formtag Will usually be the current `Page�s `newFormOpenTag()�.
*@param hiddenParams Will usually be the current `KFM_HttpServletRequest�s `toHiddenParams()�.
*/
public void setAllFormOpentag(String formtag, String hiddenParams)
{
templ.replaceAllKfm("StartForm",
formtag + hiddenParams);
}
/**
*
* @param eraseLabel if set to true, the submit button wil
* NOT be set, only an empty string will be replaced.
*
*/
public void setNextSubmitbutton(
boolean eraseLabel,
String name,
String value)
{
if(! templ.replaceKfm("action", eraseLabel ? "" : createSubmitbutton(name, value))) {
throw new ProgrammerException(
"TemplateHandler::setNextSubmitbutton: Could not replace action with name " + name
+ " and value " + value + ".");
}
}
/** */
public String createSubmitbutton(
String name,
String value)
{
return "<input type='submit' value='" + value + "' name='" + name + "'>";
}
public void write(OutputStream out)
{
templ.write(out);
}
public String writeToString()
{
return templ.writeToString();
}
public void execute()
{
templ.execute();
if(isDebug) {
templ.markCommandsLeft(); // Hm, nothing sensible to do with return value.
}
}
//
// Debugging functionality
//
public void setDebug(boolean debug)
{
isDebug = debug;
templ.setDebug(isDebug);
}
}