• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF page content in OUTLOOK body not getting breaks  RSS feed

 
tanveer hyd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a requirement. I got a JSF page(parent page). When a button(say SEND EMAIL) is pressed, an email window (OUTLOOK) will be displayed as a popup. I have to populate whatever the text data of parent page as the body of the mail.

I am using mailto method : eg :

Here is my code:
==============
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest();
context.getExternalContext().redirect(String.format("mailto:"+mailTo+"?subject=" + subject +"&body=" + body + "&cc="+mailCc+""));

till here it is fine..

My problem is body part is not getting breaks.
I have tried \n, \t, \r , <br>, <br></br> etc.. what ever stuff i found in google..

for eg my email body looks like below.. it consists of url link also.

====================================================
Hi,

This is to inform you etc... ,
Please follow this Hyperlink link to navigate to your page.. etcc.

regards..

======================================================

Any body help me.
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope that this is strictly for in-house users. Outlook doesn't run on my (Linux) desktop, so if you were planning to use this as a part of an app to sell me something, there'd be no sale.

I'm not really sure about this whole forward to "mailto:" anyway. It doesn't make sense to me.

On the other hand, you can use a straight HTML link like this:

<a href="mailto:spam@coderanch.com">Mail me!</a>

You should be able to use the JSF h:outputLink tag to generate that.

The "mailto:" URI scheme works for almost every client/OS combination. In my case, it will bring up the Evolution email client instead of Outlook, but the same general effect will occur. And you'd get your sale.
 
tanveer hyd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for the advise, issue resolved with <a href.. but still is there any way to use <h:commandLink ../> for this issue.

Thanks,
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The h:commandLink generates a JSF action method call. It has the visual appearance of a hyperlink, but it navigates like a commandButton, which is a form submit control.

The h:outputLink generates a true hyperlink and doesn't invoke JSF for navigation. Since commandLink doesn't generate a hyperlink, it isn't suitable for non-JSF actions such as "mailto:". That's why there are both commandLink and outputLink controls.

The reason for h:outputLink over a straight "<a>" tag is that the outputLink can emit a URL that's relative to the JSF webapp's URL context instead of requiring the developer to determine what context the app is deployed under and add that information manually. And because JSF is more portable when it avoids using raw HTML.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!