struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 12311] New: - Example tags would not work in a sub-application
Date Wed, 04 Sep 2002 18:44:05 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12311>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12311

Example tags would not work in a sub-application

           Summary: Example tags would not work in a sub-application
           Product: Struts
           Version: 1.1 Beta 2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Example
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: bonanno@us.ibm.com


The three tags in the Struts Example would not work if the application was 
configured as a sub application. This is because the ApplicationConfig's prefix 
is not prepended to the page. The prefix is not necessary for the example 
because the example is not normally configured as a sub application. However, 
it would probably be a good idea to modify these tags so that the example can 
demonstrate how to write a tag that would work when configured as a sub 
application with a non blank prefix.

The required modifications are relatively minor, just need to get the 
ApplicationConfig from the request object and append the ApplicationConfig 
prefix to the page.

--CheckLogonTag.java---------------------------------------

    public int doEndTag() throws JspException {

	// Is there a valid user logged on?
	boolean valid = false;
	HttpSession session = pageContext.getSession();
	if ((session != null) && (session.getAttribute(name) != null))
	    valid = true;

	// Forward control based on the results
	if (valid)
	    return (EVAL_PAGE);
	else {
	    try {
               String prefixedPage = page;
               ApplicationConfig config = (ApplicationConfig)
                  pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
               if (config != null) {
                  prefixedPage = config.getPrefix() + page;
               }
	       pageContext.forward(prefixedPage);
	    } catch (Exception e) {
		throw new JspException(e.toString());
	    }
	    return (SKIP_PAGE);
	}

    }

--LinkSubscriptionTag.java-----------------------

	// Generate the URL to be encoded
        HttpServletRequest request =
          (HttpServletRequest) pageContext.getRequest();
        StringBuffer url = new StringBuffer(request.getContextPath());
        ApplicationConfig config = (ApplicationConfig)
            pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
        if (config != null) {
            url.append(config.getPrefix());
        }
        url.append( page );

--LinkUserTag.java---------------------------------

	// Generate the URL to be encoded
        HttpServletRequest request =
            (HttpServletRequest) pageContext.getRequest();
        StringBuffer url = new StringBuffer(request.getContextPath());
        ApplicationConfig config = (ApplicationConfig)
            pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
        if (config != null) {
            url.append(config.getPrefix());
        }
        url.append( page );

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message