cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexg...@worldshack.com
Subject connecting form field to action
Date Mon, 19 Aug 2002 17:10:03 GMT
I don't understand how actions can read fields from an html form through the sitemap. I have
a 
text field in a form, i'd like to pass that field's value to an action which will eventually
modify it and 
return it to the sitemap. My action, sitemap, form can see each other and execute properly,

however the text field is not passed to the action. Is there something special i have to do
to the 
sitemap in order for this to happen?
here is the code:


in my html:
<form action="search_1.html" method="post" name="Search_Form">
  <b>Search</b>
  <input size="25" maxlength="100" name="search_string" type="text">
  <input value="..." name="cocoon-action-Search" type="submit">
</form>


in my Sitemap:
<map:actions>
     <map:action name="Search" src="Search"/>
</map:actions>

<map:match pattern="search_*.html">
   <map:act type="Search">
      <map:generate src="{proper_string}.xml"/>
   </map:act>
   <map:transform src="stylesheets/main.xsl"/>    
   <map:serialize/>
</map:match>




in my java (action):
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import java.util.Map;
import java.util.HashMap;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.xml.sax.EntityResolver;

public class Search extends AbstractAction {
  public Map act (Redirector redirector, SourceResolver resolver, Map objectModel,
                  String source, Parameters params) {
		
    Request request = ObjectModelHelper.getRequest(objectModel);
 
    Map sitemapParams = new HashMap();
    sitemapParams.put("proper_string", request.getAttribute("search_string")); 

    return sitemapParams;
  }

}





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


Mime
View raw message