<string name="text">
• Text <br />
• Text2 <br />
• Text3 <br />
</string>
I use this in strings.xml. It works fine, but I want to have more space between text and text2. In css I would just use margin-bottom. Can I do something similar here? I've tried <p></p>, but it has too much space then.
XML is not a language to be displayed just a way of recording data. You could have the data recorded in XML fed into another medium and style it there.
Related
I have persisted entity with field text. Inside text I have part to replace. myEntity.text:
some text
twoImages[12_v13.PNG, 10_v6.PNG]
text text text
twoImages[12_v13.PNG, 10_v6.PNG]
<h1>And HTML</h1>
So in view I want to use something like th:utext. But with replaced images blocks with th:fragment (~15 lines per fragment).
Output should be like this:
some text
<img .. 12_v13.PNG />
<br />
<img .. 12_v13.PNG />
<additional html />
text text text
<img .. 12_v13.PNG />
<br />
<img .. 12_v13.PNG />
<additional html />
<h1>And HTML</h1>
How to realize this with Thymeleaf?
If the entire text of the field is a single string, you will have to parse it using regex matcher or some generated parser. Say [12_v13.PNG, 10_v6.PNG] has to be parsed e.g. with
\\[([^,]),\\s([^\\]]*)]
The first group will give 12_v13.PNG, the second one - 10_v6.PNG.
You need to provide the path to each of the images in src property of img tag.
You can achieve the result this way:
<img th:src="#{/images/test.png}" />
It is implied, that /images folder is within webapp folder of your project.
<img th:src="#{/resources/images/Picture.png}" />
Output as:
<img src="/resources/image/Picture.png" />
When you hit http://localhost:8080/myapp/resources/images/Picture.png in you browser then you should be able to access the image for the above syntax to work.
This link is useful: Standard URL Syntax
Please have a look at my thymeleaf demo project: demo project (the folder with templates will get opened) You'll find data on project structure and examples of thymeleaf templates.
i have a problem with converting html output from creditor to my pdf.
I use the XMLWorkerHelper.parseToElementList method to read out the database field with the html code of the ckeditor, but not all of the content are rendered in the pdf document.
I figure out that its only affects elements of type 10 (CHUNK, if i'm right) and the content of this chunk is empty, if i print it to the console.
I reconfigure ckeditor to use <br/> instead of <p>-tags
Here an example of an html code from ckeditor:
MS Office (Word, Excel, PowerPoint)<br/>SAP<br/>Adobe Photoshop<br/>IBM SPSS Statistics<br/>EFS Survey<br/>CMS<br/>
or
Kernfach: Sozialwissenschaft<br />
Note: <u><strong>1,7</strong></u><br />
<br />
Nebenfach: Rechtswissenschaft<br />
Note: <u><strong>2,3</strong></u><br />
<br />
<br />
Abschluss: <strong>Bachelor of Arts</strong><br />
<br />
Abschlussnote: <strong><u>1,9</u></strong>
Only the text between the tags are rendered, the other/normal text are ignored
Is this a problem of misconfiguration or do i have modify the content before pass it to the XMLWorkerHelper?
i'm thankful for tips to solve my problem.
regards
Rizzi
I am using Zk framework for UI and from Controller side i need to set the value for the radio.Have a look on below code
radio.setLabel("Phone Number#"+"<span style="+"\" foreground-color:blue \""+">"+cont.getPhone().toString() +"</span>"+"Email Id"+cont.getEmail());
but it is not replacing the color,only color of phone number should be replaced
Try below line of code
If you want to do in ZUl page try this
<radio id="radiog" label="Item D" value="itemD" style="color:blue;"/>
otherwise try
radio.setStyle("color:blue;");//Their can be syntax error please modify it according to your requirement.
Take a look at my fiddle. I separate your radio in 3 components: 1 radio and 2 labels, all inside 1 div. This is the only simple way I can think of
Fiddle
Code
<zk>
<window border="normal" title="hello">
<div>
<radio id="radio" value="itemD" />
<label value="Phone: " />
<label style="color:blue" value="123456" />
</div>
</window>
</zk>
I doubt ZK allows use of HTML code inside the radiobutton label.
I suggest breaking it into smaller pieces like #AlexGreg answer shows, you can even consider using spans or try a CSS approach like the one suggested in https://stackoverflow.com/a/4622818/1385048.
You can override the client widget's implementation domLabel_() function as follows:
<radio xmlns:w="client">
<attribute name="onCreate"><![CDATA[
self.setLabel("<span style='color:blue'>test</span>");
]]></attribute>
<attribute w:name="domLabel_">
function () { return this.getLabel(); }
</attribute>
</radio>
i acheived this through a piece of code.
first create Outer Hlayout then radio button then inner hlayout
created two label's & then set css seperatly
set that lable to inner hlayout,
inner hlayout to radio
and radio to outerlayout.
I have some text which I want to have on separate lines.
I try to println this with label:
add(new Label("output",output));
<span wicket:id="output">Will be replaced</span>
Problem with this code it that it is ignoring formatting new line. Is there better way how to println some text?
There are two options:
Use a <pre /> (as in: preformatted) tag instead of <span />. If you have new line markers in your text, it will work, because browsers do not format text that is placed inside the <pre /> tag.
Use Wicket's MultiLineLabel class. After the Javadoc:
Unlike Label, MultiLineLabel shows text that spans multiple lines by inserting line breaks (BR tags) for newlines and paragraph markers (P tags) for sequences of more than one newline.
Note, that if using the MultiLineLabel class, you should not use a <span /> tag in your HTML, as placing paragraphs (<p />) inside <span /> is considered bad practice.
I am using \n in my java bean and output of the variable in console is displayed correctly. Whereas while fetching this value from bean to JSF \n seems not working.......
can any one suggest me how can i make \n work in of JSF.
The simplest way would be to apply CSS white-space: pre on the parent element containing the text of which you would like to preserve newline \n characters. Given this CSS style class:
.preformatted {
white-space: pre;
}
You could apply this as follows:
<div class="preformatted">#{bean.text}</div>
or
<h:panelGroup layout="block" styleClass="preformatted">#{bean.text}</h:panelGroup>
or
<h:outputText value="#{bean.text}" styleClass="preformatted" />
etc.
This style property is by the way also exactly what the <textarea> element is by default using. You could also make use of it and make it uneditable by setting disabled="true" or readonly="true".
<h:inputTextarea value="#{bean.text}" disabled="true" />
You can of course also replace all occurrences of \n by the HTML <br/> element. This way you can display it in an element which does not use white-space: pre and/or is not a <textarea> element. One of the ways is using fn:replace().
<h:outputText value="#{fn:replace(bean.text,'\\n','<br/>')}" escape="false" />
This is IMO only uglier than white-space: pre.
You should replace all \n with <br/> before you send the value to your <h:inputTextarea>.
Html uses <br/> for line break and not the \n like java.
Also, you should add escape="false" to your <h:outputText (almost sure...).
Replace all occurrences of \n with </br> before displaying it.
When looking into text recorded in my database via a <h:inputTextarea> I found that special characters were being persisted.
Thus, after investigating what I thought was some dark art of persistence, I appreciated that the default display of the JSF component was in fact what was letting me down.
I shortly found that adding white-space: pre-wrap; to <p> on my stylesheet fixed this problem for my <h:outputText> tags which were being supplied with text from a JPA pojo.
In my case, I needed pre-wrap rather than pre because pre was wrapping by character, rather than by word.
Hope this helps someone!
I have solved it using the following method
Declare an inputtextarea where a user can provide multi-line description. Before saving it to database, I have replaced new line to branch
String fpDescriptionCombined = fpDescription.replaceAll("(\r\n|\n)", "<br />");
During showing in screen, i again replaced branch to new line
String finalStr = splitStr.replaceAll("<br />", "\n");
In screen, I used above-mentioned CSS
.showLineBreak {
white-space: pre;
}
<h:outputText value="${templateListController.getFlowPointDescriptionForTab(eachFPType)}" style="display:block;width:860px;" styleClass="showLineBreak" />
I had to do this because my description can be exported/imported via csv. So adding multi-line description will be treated as a new record if not handled properly