You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Juan Alvarado <ju...@yahoo.com> on 2004/07/11 02:39:32 UTC

html tags in resource bundle

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!

Re: html tags in resource bundle

Posted by Juan Alvarado <ju...@yahoo.com>.
Great Greg I will give your suggestion a try.
 
Thanks

Greg Ludington <gl...@gmail.com> wrote:
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. 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 login 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
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 login 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

Re: html tags in resource bundle

Posted by Juan Alvarado <ju...@yahoo.com>.
Ok I gave this a try and it worked. However something VERY weird happened.
 
Since I am using tiles, all of my forwards go to a tiles definition. When I tried your suggestion:

String replacementLink = mapping.findForward("audit.app.login").getPath();

super.saveMessage(request, "auditapp.login.duplicate.user.error", (String)f.get("email"), replacementLink);

return mapping.getInputForward();

the name of the tiles definition in the forward audit.app.login was inserted into the link:

<a href="audit.app.login">login</a>

but when I click on the link, I do get to the login page. Like I said in my original email, I am just picking up struts again after a break from it so I am not aware of all the changes that have been made to the framework recently. I would however would like to know that this is normal behavior.

Thanks again for your help!!!

Juan

Greg Ludington <gl...@gmail.com> wrote:

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. 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 login 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
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 login 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Re: html tags in resource bundle

Posted by Greg Ludington <gl...@gmail.com>.
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
<ju...@yahoo.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org