You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Garvin Riensche <g....@gmx.net> on 2005/05/03 11:52:58 UTC

CForms with actions

Hi there,

I want to figure out how CForms are working in combination with actions 
instead of flowscripts. Therefore I want to create an simple example 
like this: http://cocoon.apache.org/2.1/userdocs/forms/sample.html but 
without the flowscript.
The only example for CForms with actions I know can be found at the 
cocoon-blocks but it lacks documentation and is a bit too complex for 
me. So, what I did so far is, writing the form definition, the template 
file, the sitemap and one action.
If I unterstood it correctly one only has to write one java-file to 
initialize the form. The other actions that are needed are
org.apache.cocoon.forms.acting.MakeFormAction
and
org.apache.cocoon.forms.acting.HandleFormSubmitAction

But I am not sure how to the "initialize-action" has to look like and 
how i compile it correctly. I wrote it like this:

FormAction.java

import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.forms.acting.AbstractFormsAction;
import org.apache.cocoon.forms.formmodel.Field;
import org.apache.cocoon.forms.formmodel.Form;
import org.apache.avalon.framework.parameters.Parameters;

import java.util.Map;
import java.util.Date;

public class FormAction extends AbstractFormsAction {
    public Map act(Redirector redirector, SourceResolver resolver, Map 
objectModel, String source, Parameters parameters)
            throws Exception {
        String formSource = parameters.getParameter("form-definition");
        String formAttribute = parameters.getParameter("attribute-name");

        Form form = formManager.createForm(resolver.resolveURI(formSource));

        Request request = ObjectModelHelper.getRequest(objectModel);
        request.setAttribute(formAttribute, form);

        return null;
    }
}

And I tried to compile it with

javac -classpath i:\projekte\cocoon-2.1.7\build\cocoon-2.1.7\classes 
-sourcepath 
I:\projekte\cocoon-2.1.7\src\blocks\forms\java;I:\projekte\cocoon-2.1.7\lib\core\excalibur-sourceresolve-1.1.jar 
Fo
rmAction.java

but I get 100 errors which seems to come from the source files in 
..\forms\java\. But when I leave out the sourcepath to these files i get 
serveral errors like:

FormAction.java:5: package org.apache.cocoon.forms.acting does not exist
import org.apache.cocoon.forms.acting.AbstractFormsAction;

My question is, if my gerneral approach to create a form with actions is 
correct and if yes, how do i compile this java file.

regards,
Garvin








---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org