Web Ratio using a web service, how to output newline in html? - html

I want to use a web service provider (made by me) in my WebRatio project, the service I developed return a string properly formatted with newline, I try to use either \n or the <br> html tag (in the output string).
In the html document, Web ratio converts \n in spaces and prints the <br> tags as text.
How can I insert html tags (like <br>) in the page?
Edit:
Here is the output of the service (in Java)
public String toString(){
return "News \n title=" + title + "\n";} //I try using <br> instead of \n
And here is the html
<td class="value"> <!--all this HTML is printed in the same line-->
News
Titolo=bla bla
....
</td>
Using the <br> tag the main problem is to make Web Ratio avoid the conversion from the <br> output tag to a <br>

I don't know if you resolved your problem. Anyway you can manage the text as html.
For example if you want to show the text in the Message component and set "html" as content type, please follow these steps:
Select the Message component in the Layout -> Grid -> Message
component
Click on the Layout Parameters (blue button) of the Component Layout Property available in the Properties View
Select the option "text/html" for the "Content Type" Parameter (this is available in the WRDefault/Normal template).
In this way you can see the text as html.
Moreover if you want fill in a form field with the html text you have to set "html" as "Content type" Property: Select the Field in the Outline View and select "text/html" item for the "Content Type" Property available in the Properties View.
To set html as default content type for a string (or text) Attribute defined on an Entity (in the Domain Model) you can refer to the "Content Type" Property of the selected Attribute.
I hope this will help you to solve the problem.

Related

How to separate text and links from an input textarea using a jsp page?

I´m really bad at programming, and I´m trying to do a web aplication using html and jsp pages, the application have to allows the users to post things, and well that is the problem, because I can´t separate text and links from the textarea.
There is the method to post.
<div id ="post">
<form method="post" action="Validaciones.jsp" >
<textarea name="comentario" rows="4" cols="20" maxlength="140" id="coment" >
</textarea>
<button name="publicar" value="publicar">Publicar</button>
</form>
</div>
But so, when I do:
String texto = request.getParameter("comentario");
It return the parameter as a String, so if a put, "Hello visit my page: www.ducks.com", there is a way to know what is text and what is the link?
Because the aplication have to show the links as links, with the (a) tag.
Thanks for the help.
Dont use plain textarea.You need to use editors like CKEditor,TinyMce(to name a few).
These editors help to maintain the text formatting and save it into the database.So when you view this on another page you will be able to see whatever you had written earlier in the editor.Hence these editors are called WYSIWYG (What-You-See-Is-What-You-Get)
So use these editors in your page.
Use regular expressions
Pattern p = Pattern.compile("^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0‌​-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$", Pattern.CASE_INSENSITIVE);
String toMatch = "this is a URL http://google.com";
Matcher m = p.matcher(toMatch);
With the url , use substring for the string.

Using Razor to get HTML from Resource File

I am storing this string within a ResourceFile:
Please select a #Html.ActionLink("Personal", "PersonalAccount", "Help"),
or a #Html.ActionLink("Corporate", "BusinessAccount", "Help") account.
Now I want to put this content on a Span element inside the Title attribute.
I tried this without success :
<span class="tooltip-icon tooltip"
title="#Html.Raw(HttpUtility.HtmlDecode(ToolTips.AccountType))">
</span>
The issue is that I am seeing the regular text, not the content encoded.
Razor is not going to double parse your page, It parses your page and renders the content of your resource which is a text having # in it(Please select a #Html.ActionLink("Personal", "PersonalAccount", "Help")). It doesn't care what is in the resource.
Any how, you can't do it this way and you shouldn't, the only culture specific part of your code is the link's text which you should just put that part in your resource file not whole of that line.
Using VahidND suggestion I was able to do it without Razor inside the Resource file.
So I actually ended with this :
<span class="tooltip-icon tooltip"
title="#String.Format(ToolTips.PTAccountTypeRadio1,
Html.ActionLink(ToolTips.PTAccountTypeRadio2, "PersonalAccount", "Help"),
Html.ActionLink(ToolTips.PTAccountTypeRadio3, "BusinessAccount", "Help"))"
</span>

set html in tinymce editor

i am trying to set HTML data in tinymce using jquery. But i have some problem in it.
my html data is as :
var data = "<div><img src='http://localhost/images/test.png' /><div>Image Title</div></div> html";
tinyMCE.activeEditor.setContent(data , {format : 'raw'} );
It renders the div and image properly. but i get additional tag with html in it
If i remove the html word the data is not properly rendered in editor
I also tried various below combination, but it did not helped:
tinyMCE.activeEditor.dom.setHTML(tinyMCE.activeEditor.id, str);
tinyMCE.activeEditor.setContent(data );
Tinymce and the browser taking care of the validity of the html entered.Can you show me the editor content after you entered your data?
tinyMCE.activeEditor.setContent(content);
is the usual correct way to replace the current editor content with the text that the content variable hold.

Show html code as rendered html text

I am trying to take some input from the user with the wisywig text editor plugin. But, when I try to show the text in a label or paragraph, all the html tags become visible.
For example,
#string str = "<b>sample text</b>";
<label>#str</label>
should look like
sample text
But it is not. It looks like,
<b>sample text</b>
How can I render a html code string into a html text...???
i am working with .net mvc3 with razor view engine...
That may happen if HTML entiries are being encoded.
You need to avoid that encoding or do decoding. For example, in PHP you can use http://php.net/manual/en/function.html-entity-decode.php to decode HTML entities.

Need to render HTML with Play parameters

I have an object that has a title and some text (item.itmTitle and item.itmText) which I am passing to an HTML template using Play's render() method. Within the template (which in this case is called "index.html) I am trying to display the contents of the item object:
.
.
.
<p class="title">${item.itmTitle}</p>
<div id="itemtext">${item.itmText}</div>
.
.
.
My problem is this: the contents of item.itmText are HTML formatted. What I would like is for the contents to be displayed as HTML, but what is happening is that Play is doing all necessary conversions to display the contents as text. In other words, if item.itmText has the following HTML:
<p>This is a paragraph formatted in HTML</p>
The play template converts the source as follows:
& lt;p& gt;This is a paragraph formatted in HTML& lt;/p& gt;
My question is: is there some way to stop this conversion and make the HTML appear on the page as renderable HTML?
Someone please advise.
${item.itmTitle.raw()}
You just need to make sure that these strings are guaranteed to be safe; e.g. if users are submitting the title or text you need to sanitize the content to prevent injection of javascript (or accidental breakage of your container tags).