You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lydia P <ly...@attglobal.net> on 2003/06/18 19:14:49 UTC

Struts Actions and redirected URL's

Any suggestions will be greatly appreciated!

I have a search Action that returns a list of objects in tablular format 
from a query to one database table.
An object can be selected via a radio button, and deleted via a "Delete" 
button/Action.

The delete Action checks to see if this object exists in another 
database table.  If the object exists in other tables, I do not want the 
object deleted from the main table.  The logic for delete works fine, 
however, I want to let the user know WHY the object isnt being deleted, 
I am already using errors.add in other places, but can not use it here 
because of a different way of forwarding.
The results list table from the search has a URL that looks like :
context-root/inventory/executeSearch.do
 If I use :
    return (mapping.findForward("success"));
Then an application resource message can be returned , but the URL for 
the original page is lost and it shows:
context-root/inventory/delete.do?serial=1122357&returnUrl=L2FjdGl2YXRlL2ludmVudG9yeS9leGVjdXRlU2VhcmNoLmRv

To resolve the URL problem, here is the URL code snippet with its 
corresponding actionForward:
String base64ReturnUrl= form.getReturnUrl();
            String returnUrl = null;
            if (base64ReturnUrl!=null){
                //get rid of the "/activate" from the url since the 
ActionForward will tack
                //that on as a result of the contextRelative == true setting
                returnUrl=Base64.decode(base64ReturnUrl);
                int startIndex = returnUrl.indexOf("/",1);
                returnUrl=returnUrl.substring(startIndex);
.
.
.
            ActionForward forward = new 
ActionForward("dynDelRedirect",returnUrl, true, true);
            return forward;


Action mapping for this action in struts-config.xml:
        <action path="/delete" 
type="com.activate.inventory.actions.InventoryDelete" 
name="inventoryFormEdit" scope="request" validate="false" 
roles="InventoryDeleters">
            <exception key="errors.unknownExceptionMsg" 
path="tiles.generalError.page" 
type="com.activate.inventory.InventoryDelegateException"/>
            <forward name="success" path="tiles.inventory.search" 
redirect="false">
            </forward>
        </action>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org