One possibility would be to create a forward (local or global) for the
Action you wish to link, and then, when you save ActionMessages,
create the link, and then pass it as a parametric replacement to the
message.

1) in struts-config.xml, create a forward that maps to the action link
you want in your message, e.g. <forward name="appRegisterLoginForward"
path="/appRegisterLogin.do"/>.

2) Set your message to have another replacement, like:
auditapp.login.duplicate.user.error=A user with email address: {0}
already exists. If that is your email address, please use that email
address as your <a href="{1}">login</a> along with the password you
were supplied.

3) In your Action, obtain the path of the forward, get its path, and
place it in the message.  Using your code as a basis:

catch(DuplicateUserException dupEx){
log.error("Caught DuplicateUserException in execute.... of
AuditAppRegistrationAction");

// This is the link created from the forward you defined in step 1
String replacementLink =
mapping.findForward("appRegisterLoginForward").getPath();
super.saveMessage(request, "auditapp.login.duplicate.user.error",
(String)f.get("email"), replacementLink);
return mapping.getInputForward();
}

This way, the creation and rewriting of the link itself is handled by
normal struts mechanisms, and you can manage the links in your
struts-config.xml file.


On Sat, 10 Jul 2004 17:39:32 -0700 (PDT), Juan Alvarado
<[EMAIL PROTECTED]> wrote:
> Hello everyone:
> 
> I have recently started using struts again and I am a bit rusty so please bear with 
> me. I searched the list for what I need and I didn't find anything.
> 
> What I need is to display to a user a message in a JSP. This message is pulled from 
> an ApplicationResources.properties file. What  I would like to do is to be able to 
> display a link to another page in this particular message.
> 
> My key looks like this:
> auditapp.login.duplicate.user.error=A user with email address: {0} already exists. 
> If that is your email address, please use that email address as your <html:link 
> action='/appRegisterLogin'>login</html:link> along with the password you were 
> supplied.
> 
> As you can see it has a struts specific html tag. This of course didn't work. Does 
> anyone know of an equivalent way to do this. I could use regular html tags (although 
> I haven't tried it) but I would like to stick with the struts specific stuff as much 
> as I can. Especially since it will handle url rewriting for you. The above key gets 
> pulled from an action with the following code:
> ...
> 
> catch(DuplicateUserException dupEx){
> 
> log.error("Caught DuplicateUserException in execute.... of 
> AuditAppRegistrationAction");
> 
> super.saveMessage(request, "auditapp.login.duplicate.user.error", 
> (String)f.get("email"));
> 
> return mapping.getInputForward();
> 
> }
> 
> If you have a solution, ideas or suggestions I would appreciate it if you shared 
> them with me.
> 
> Thanks in advance.
> 
> Juan
> 
> 
> ---------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to