Well, there's something to be said for having a set of really nice little sample apps readily available from your project. I know this mavforum thingy is not worthy of an entire sourceforge project setup. Also, having another project with a life of its own would probably drive me that last little distance over the fine line dividing genius and insanity :-)
Anyway, I'll probably host it someplace where I can. One question though: If I turned it into a blow-by-blow tutorial for writing Maverick apps, would you be interested in posting the code then? Possibly taking it over for me? Hmmm?
Zed
On Monday, January 6, 2003, at 12:07 PM, Schnitzer, Jeff wrote:
Sure, that could work - but why not simply set up an additional sourceforge project? We would be happy to link to it in the documentation and on the Maverick website navbar.I've been working on a rewrite of the Punk Image Gallery since the existing code is quite dated (it is still based on Maverick 1.x). I'm planning on moving it to a separate SF project. Plugins make a lot of sense to put in the Maverick CVS, but big sample apps probably deserve their own SF project - they're more likely to take on a life of their own that way. BTW, I am also really interested in a small and simple threaded forum system. I have a few applications for which Jive is just far far too heavy. Jeff Schnitzer [EMAIL PROTECTED]-----Original Message----- From: David Cuthill [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 11:45 AM To: [EMAIL PROTECTED] Subject: Re: [Mav-user] A Controller with Integrated FormProc features Hi Zed, I for one, would be interested in perusing the full source to your webapp. In a few weeks I will be starting a new project for which Ihavealready specified components similar to yours: Maverick, Hibernate and some heavy form validation (FormProc?). Perhaps Jeff and the guys could set up a '3rd party' CVS branch, where submissions such as yours can be published, which enhances the project whilst keeping the core code branch clean and lightweight? David Cuthill Zed A. Shaw wrote:Hi folks, I've been playing with several different web application frameworks,anddecided to spend some time writing up a real simple little threaded discussion board in Maverick. I also managed to write a fairlycompletebase controller which integrates with FormProc to give you semi-automated form validation. I thought I'd send it to the listtosee what people think. I've attached the maverick.xml and the SuperController.java files for people to look at. I also threw inoneof the derived controllers to show how it is used. The entirethreadeddiscussion forum is much to large to put in an e-mail, but I maythrowit up on a website somewhere if people are interested in it as a learning project. Anyway, Maverick is really cool. Thanks for the good work. Haveyouguys thought of hooking up some XDoclet stuff like struts andwebwork----------------------------------------------------------------------- -have done?
package com.zedshaw.mavforum.control; import com.zedshaw.mavforum.data.*; import cirrus.hibernate.*; import org.infohazard.maverick.ctl.*; import org.infohazard.maverick.flow.*; import java.util.*; import org.formproc.*; import org.formproc.servlet.*; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; /** * Description of the Class * *@author zedshaw *@created December 16, 2002 */ public class ForumList extends SuperController { /** * Description of the Method * *@param controllerNode Description of the Parameter *@exception ConfigException Description of the Exception */ public void init(org.jdom.Element controllerNode) throwsConfigException {// we only do this in the ForumController so that it isdoneoncesuper.init(controllerNode); HibernateManager.init(); } /** * A logger for printing out messages. */ private static Log log = LogFactory.getLog(ForumList.class); /** * Constructor for the ForumController object */ public ForumList() { super(); } /** * Description of the Method * *@param ctx Description of the Parameter *@param formResult Description of the Parameter *@param formModel Description of the Parameter *@return Description of the Return Value *@exception Exception Description of the Exception */ public String perform(ControllerContext ctx, FormResultformResult,Map formModel) throws Exception {// get the forums and set them up as the model Session sess = HibernateManager.getSession(ctx); boolean hasErrorr = false; // clear out the currentForumctx.getRequest().getSession().setAttribute("currentForum",null);try { List forums = sess.find("from forums in classForum");ctx.setModel(forums); } catch (Exception e) { ctx.setParam("errorReason", "Problem listing allthe----------------------------------------------------------------------- -forums.");e.printStackTrace(); hasErrorr = true; } finally { sess.disconnect(); } return hasErrorr ? ERROR : SUCCESS; } }
package com.zedshaw.mavforum.control; import org.infohazard.maverick.ctl.*; import org.infohazard.maverick.flow.*; import java.util.*; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.MethodUtils; import javax.servlet.*; import javax.servlet.http.*; import org.formproc.*; import org.formproc.servlet.*; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; import org.jdom.*; /** * Description of the Class * *@author zedshaw *@created December 16, 2002 */ public class SuperController implements ControllerSingleton { /** * Common name for the typical "success" view. */ public final static String SUCCESS = "success"; /** * Common name for the typical "error" view. */ public final static String ERROR = "error"; /** * Indicates that there is an error in the form submitted. */ public final static String FORM_ERROR = "form_error"; /** * This is the prefix for the methods, which the ACTION_KEY isappended to*/ public final static String PERFORM_PREFIX = "perform"; /** * A logger for printing out messages. */ private static Log log =LogFactory.getLog(ControllerSingleton.class);/** * The form manager used by this controller to verify forms. */ protected FormManager formManager = null; /** * The name of the form to use when processing the input. */ protected String formName = null; /** * Determines whether to use an ExtendedHttpForm or not. */ protected boolean isFormExtended = false; /** * Determines whether the form errors should be passed throughtothe* controller or if an error in the form should be rejectedwithFORM_ERROR. A* value of true means to pass the errors on to the controlle,andfalse means* to reject. */ protected boolean isFormPassed = false; /** * Description of the Field */ protected boolean hasForm = false; /** * Initializes the singleton with the configuration node. * *@param controllerNode Description of the Parameter *@exception ConfigException Description of the Exception */ public void init(org.jdom.Element controllerNode) throwsConfigException {try { formManager = new FormManager(); } catch (Exception e) { log.error("Could not start the FormManager toprocessforms:" + e);throw new ConfigException(e); } // process the <form> tags inside our controllerstatementList children = controllerNode.getChildren("form"); Iterator i = children.iterator(); // there should only be one form tag, so we just do onehasNext() checkif (i.hasNext()) { Element el = (Element) i.next(); log.info("Element: " + el + " " +el.getAttribute("name") + " " + el.getAttribute("extended"));try { formName =el.getAttribute("name").getValue();} catch (Exception e) { log.error("Could not read name attributeofform");} try { isFormExtended =el.getAttribute("extended").getBooleanValue();} catch (Exception e) { // this means that the extendedattribute was notset, so we default to isFormExtended=false} try { isFormPassed =el.getAttribute("pass").getBooleanValue();} catch (Exception e) { // this means that the attribute was notset, sodefault to false} hasForm = true; } else { log.debug("Controller does not have a form,results willbe raw request input.");hasForm = false; } } /** * Sets up the servlet parameters and calls through to theparameterless* rawPerform() method. Does not result in bean population. * *@param cctx Description of the Parameter *@return Description of the Return Value *@exception ServletException Description of the Exception *@see Controller#perform */ public final String go(ControllerContext cctx) throwsServletException {Map processedModel = null; FormResult result = null; String performResult = null; // figure out if this controller has a form if (hasForm) { processedModel = new HashMap(); try { if (isFormExtended) { ExtendedHttpForm form = newExtendedHttpForm(formName, processedModel);formManager.configure(form); result =form.process(cctx.getRequest());} else { HttpForm form = newHttpForm(formName,processedModel);formManager.configure(form); result =form.process(cctx.getRequest());} } catch (Exception e) { log.error("Problem processing form " +formName +" because of: " + e);return FORM_ERROR; } // reject the submission to the FORM_ERROR viewif theform is not requested to be passed and// it is invalid. Otherwise, the goods are justpassedon to the perform method.if (!isFormPassed && !result.isValid()) { // looks like there were problems cctx.setModel(result); return FORM_ERROR; } } else { // since they don't have a form, then we justset theprocessed model to the parameter maplog.warn("no form specified"); processedModel =cctx.getRequest().getParameterMap();} try { performResult = perform(cctx, result,processedModel);} catch (Exception e) { // TODO: add exception handling e.printStackTrace(); throw new ServletException(e); } return performResult; } /** * This is the base perform method which does nothing butreturnsuccess.* *@param ctx Description of the Parameter *@param formResult Description of the Parameter *@param formModel Description of the Parameter *@return Description of the Return Value *@exception Exception Description of the Exception */ public String perform(ControllerContext ctx, FormResultformResult,Map formModel) throws Exception {log.error("Perform method called in SuperController,which----------------------------------------------------------------------- -means it wasn't properly overridden.");return SUCCESS; } }
----- Zed A. Shaw http://www.zedshaw.com/------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]
----- Zed A. Shaw http://www.zedshaw.com/ ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com [INVALID FOOTER]
