You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zheng, Gang" <Gz...@3eti.com> on 2003/02/04 18:48:16 UTC
RE: Obtaining valid ModuleConfig.
Hi,
I just subscribe to the mailing list and this is exactly what I got from the
example code.
The ModuleConfig is actually stored in the ServletContext (application
context) rather than request context. So you have to modify the code to:
ModuleConfig config = (ModuleConfig) pageContext.getServletContext()
.getAttribute(org.apache.struts.Globals.MODULE_KEY);
I tested it and it works.
Hope this is helpful.
-Gang
--------------------------
Hi,
I'm using the following snippet in taglib code but it fails as config==null.
(Stuts 1.1 b3)
public int doEndTag() throws JspException {
<snip>
ModuleConfig config = (ModuleConfig) pageContext.getRequest()
.getAttribute(org.apache.struts.Globals.MODULE_KEY);
if (config == null) {
System.out.println("config == null");
}
if (config.getPrefix() == null) {
System.out.println("config.getPrefix() == null");
}
try {
pageContext.forward(config.getPrefix() + page);
} catch (Exception e) {
throw new JspException(e.toString());
}
return (SKIP_PAGE);
}
The code is based on the example that comes with struts. I presume I'm
missing something obvious but I'm new to Struts and can't track it down.
Could someone give me some pointers before I tear all my hair out ;-)
Regards
/James
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Obtaining valid ModuleConfig.
Posted by Andrew Kuzmin <ku...@soft-ukraine.com>.
Hi !
ModuleConfig config =
org.apache.struts.util.RequestUtils.getModuleConfig(pageContext); // since
1.1b3
--
Andrew Kuzmin
----- Original Message -----
From: "Zheng, Gang" <Gz...@3eti.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, February 04, 2003 7:48 PM
Subject: RE: Obtaining valid ModuleConfig.
> Hi,
>
> I just subscribe to the mailing list and this is exactly what I got from
the
> example code.
>
> The ModuleConfig is actually stored in the ServletContext (application
> context) rather than request context. So you have to modify the code to:
>
> ModuleConfig config = (ModuleConfig) pageContext.getServletContext()
> .getAttribute(org.apache.struts.Globals.MODULE_KEY);
>
> I tested it and it works.
>
> Hope this is helpful.
>
> -Gang
>
>
> --------------------------
> Hi,
>
> I'm using the following snippet in taglib code but it fails as
config==null.
> (Stuts 1.1 b3)
>
> public int doEndTag() throws JspException {
> <snip>
> ModuleConfig config = (ModuleConfig) pageContext.getRequest()
> .getAttribute(org.apache.struts.Globals.MODULE_KEY);
> if (config == null) {
> System.out.println("config == null");
> }
> if (config.getPrefix() == null) {
> System.out.println("config.getPrefix() == null");
> }
> try {
> pageContext.forward(config.getPrefix() + page);
> } catch (Exception e) {
> throw new JspException(e.toString());
> }
> return (SKIP_PAGE);
> }
>
> The code is based on the example that comes with struts. I presume I'm
> missing something obvious but I'm new to Struts and can't track it down.
> Could someone give me some pointers before I tear all my hair out ;-)
>
> Regards
>
> /James
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org