
net.officefloor.example.pageflowhttpserver.TemplateLogic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of PageFlowHttpServer Show documentation
Show all versions of PageFlowHttpServer Show documentation
Example of using OfficeFloor for page flow within a HTTP Server
The newest version!
/*
* OfficeFloor - http://www.officefloor.net
* Copyright (C) 2005-2011 Daniel Sagenschneider
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package net.officefloor.example.pageflowhttpserver;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import javax.sql.DataSource;
import net.officefloor.plugin.web.http.template.HttpSessionStateful;
import net.officefloor.plugin.work.clazz.FlowInterface;
/**
* Example logic for the template.
*
* @author Daniel Sagenschneider
*/
// START SNIPPET: class
@HttpSessionStateful
public class TemplateLogic implements Serializable {
private List- items = new LinkedList
- ();
// END SNIPPET: class
// START SNIPPET: flows
@FlowInterface
public static interface PageFlows {
void getNoItems();
void endListItems();
}
// END SNIPPET: flows
// START SNIPPET: items
public Item[] getItems() {
return this.items.toArray(new Item[this.items.size()]);
}
// END SNIPPET: items
// START SNIPPET: control
public void getListItems(PageFlows flows) {
if (this.items.size() == 0) {
flows.getNoItems(); // skip to getNoItems task
}
}
public void getNoItems(PageFlows flows) {
if (this.items.size() > 0) {
flows.endListItems(); // skip to endListItems task
}
}
// END SNIPPET: control
// START SNIPPET: addItem
public void addItem(Item item) {
this.items.add(item);
}
// END SNIPPET: addItem
// START SNIPPET: clear
public void clear() {
this.items.clear();
}
// END SNIPPET: clear
/**
* Inner class for extra dependency example.
*/
public static class ExtraDependencyExample {
// START SNIPPET: extraDependency
public void getNoItems(PageFlows flows, DataSource dataSource) {
// code requiring DataSource
}
// END SNIPPET: extraDependency
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy