cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Claude Moissinac" <moissi...@enst.fr>
Subject Re: Getting a parameter from the header or from a dynamic XML document
Date Sat, 25 Mar 2006 17:20:56 GMT
I've just tried it but it doesn't work.

My solution is a brute force tools for now: I have writed an action
which do the trick:

public class GetTerminalAction extends ServiceableAction  implements ThreadSafe{

    public final static String TERMINAL_NAME         = "terminal";
	/* (non-Javadoc)
	 * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
org.apache.cocoon.environment.SourceResolver, java.util.Map,
java.lang.String, org.apache.avalon.framework.parameters.Parameters)
	 */
	public Map act(Redirector redirector, SourceResolver resolver,
			Map objectModel, String source, Parameters parameters)
			throws Exception {
        Request request = ObjectModelHelper.getRequest(objectModel);
        Map map = new HashMap();
        boolean known =false;

        if (request != null) {
            Enumeration headers = request.getHeaderNames();
            if ( headers != null ) {
            	while (headers.hasMoreElements()) {
                    String header = (String)headers.nextElement();
                    if (header.equals("terminal"))
                    {
                    	map.put(TERMINAL_NAME, request.getHeader(header));
                    	known = true;
                    }
                }
            }
        }
        if (known==false)
        	map.put(TERMINAL_NAME, "unknown");
         return (map);
	}
}

I'm always hoping for a more elegant solution.

On 3/25/06, Laurent Perez <hakimm@gmail.com> wrote:
> Have you tried {request-header:name} ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


--
--
Jean-Claude Moissinac
Department of Computer Science and Networks
ENST Paris
FRANCE

E-mail: moissinac@enst.fr
Tel: (+33) 1.45.81.80.88
Fax: (+33) 1.45.81.71.58

http://shadok.enst.fr/jcm

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


Mime
View raw message