I want to display character \u0141 i.e the 'L' with a stroke. I have appended this unicode to the field to be displayed in the report & it displays fine in the iReport preview PDF. But when I generate the same report from my web application it displays blank i.e the character is not displayed in the pdf. I'm using JasperReports 3.5.3.
Use a custom expression in ireport to solve the issue and in your custom class write the logic to
convert unicode to text .
public class Unifun {
public static String convertunitostring(String s) {
return StringEscapeUtils.unescapeJava(s);
}
public static void main(String args[]) {
System.out.println(convertunitostring("\ufeff\u0110\u1eaf\u0063\u0020\u004c\u1eaf\u0063"));
}
}
Related
I'am populating a ListView with images.
In pseudocode:
populateItem(model){
load base64 from database
image.setDefaultModel(base64)
The image is just a webcomponent and in html it is just <img src="">
How can i show a indicator while the image is loaded?.
I first thought of adding IAjaxIndicatorAware but this triggers the indicator when the image is doing an AjaxRequest.
Since you seem to load and display the image as a Base64 src it will directly get send in the html response and not loaded later (in contrast to images with a src that links to another URI).
You could wrap the image in an AjaxLazyLoadPanel.
This will first display an AjaxIndicator while the content is generated and get later replaced by the actual loaded content once it is done loading/generating:
edit
I got an Exception : Component must be applied to a tag of type [img].
i didn't consider that problem. AjaxLazyLoadPanel allways uses a <div> as a html tag to display the component it loads. To display a base 64 image you would need to wrap it in another Panel:
public class Base64ImagePanel extends Panel {
public Base64ImagePanel(String wicketId, String base64Data, String contentType) {
super(wicketId);
WebMarkupContainer image = new WebMarkupContainer("image") {
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
checkComponentTag(tag, "img");
tag.put("src", "data:" + contentType + ";base64," + base64Data);
}
}
add(image);
}
}
Base64ImagePanel.html:
<wicket:panel>
<img wicket:id="image"></img>
</wicket:panel>
And then use that wrapper Panel in the AjaxLazyLoadPanel:
add(new AjaxLazyLoadPanel("imageLazyLoad") {
#Override
public Component getLazyLoadComponent(String id) {
//load your actual base64 from database, i use some example Strings for demonstration in the following line
Base64ImagePanel imagePanel = new Base64ImagePanel(id, "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", "image/png");
return imagePanel;
}
});
I have a word document file in which I added a Section Break of Next Page, now I want to change the header and footer of that page.
Scenario of example, I have a doc file which has four pages with headers and footers and added fifth page in the section break next page, I want to change the header and footer of the fifth page only. This is achievable manually by deselecting the Link to Previous button in the Word Application but I don't know how to change it using XML?
My code that adds the new page in the section breaks is:
class Program
{
static void Main(string[] args)
{
string path = #"C:\sample.docx";
string strtxt = "Hello This is done by programmatically";
OpenAndAddTextToWordDocument(path,strtxt);
}
public static void OpenAndAddTextToWordDocument(string filepath, string txt)
{
using (DocX document = DocX.Load(#"C:\Riyaz\sample.docx"))
{
document.InsertSectionPageBreak();
Paragraph p1 = document.InsertParagraph();
p1.Append("This is new section");
document.Save();
}
}
}
Please help.
ok, let say I got:
CheckBox myCheckBox=new CheckBox("http://verylongurlverylonngurl_image.jpg");
I wanna hide the part http://verylongurlverylonngurl_ of the text of checkbox, ie when seeing the check box on website it will show "image.jpg" as text of checkbox, but when we getText of that checkbox:
myCheckBox.getText();
it will return string "http://verylongurlverylonngurl_image.jpg"
It looks like you'd want getText() to be image.jpg and use getFormvalue() to get the full value: getText() is the displayed text, getFormvalue() is the actual value of the checkbox.
You can create your own widget, if you only want to use it with myCheckBox.getText();
public class TextShortenedCheckBox extends CheckBox{
private String original;
public CheckBox(String label, int visibleLength){
super(label.subString(visibleLength));
original=label;
}
#Override
public String getText(){
return original;
}
}
This is one way to go.
I need to send a SafeHtml to Window.setTitle().
The problem is that i use SafeHtmlUtils.fromString(String c) on the title.
Due to chance of XSS Leaks.
The result is that i get a bad looking title (due to the conversion SafeHtmlUtils.fromString to HTML Entity References)
My question is can you set the Window title with a SafeHtml?
Or how do i convert the Safehtml back to normal String?
code (updated):
public void setTitle(SafeHtml title) {
internalHeader.setPageTitle(title);
Window.setTitle(("fileee | " + title).replaceAll("\\<.*?>", ""));
}
//in internalHeader
public void setPageTitle(SafeHtml title) {
pageNameBig.setInnerSafeHtml(title);
}
pageNameBig is a HeadingElement.
Problem is that if i put in <h1>test the result is in Window.setTitle = <h1>test
but in the internalHeader is good = dispalys <h1>test
Is all because of its HTML Entity References.
It isn't possible for XSS on the title of the window because the title can't render HTML.
SafeHtml.asString() will get you a string, though not the original from SafeHtmlUtils.fromStrong - instead, since the window title can't display any HTML, there is no need to use SafeHtml at all.
I am trying to create a ListBox using GWT. I am using UiBinder to create the field.
I would like to set a default text on the list box and when a user clicks on the box, it should show me the list items. Once again, if user has not selected any option, it should show me the default text again.
Any way to do this either using Uibinder or some ListBox methods?
If I understand correctly you want a value to show but when the user clicks on the list it disappears and shows you the list items?
As far as I know there is no option to that natively.
What you can do is add the first item to hold your default value.
You can do this grammatically by using addItem in code or using:
<g:Listbox>
<g:item value="-1">Default text</g:item>
</g:Listbox>
works with gwt 2.1+
The value can still be selected.
You can choose to ignore it or add an attribute "disabled" with value "disabled" to the option element:
listbox.getElement().getFirstChildElement().setAttribute("disabled" ,"disabled" )
hope it helps a bit :)
You can also use a renderer to control what is shown if 'Null' is selected.
(Inspired by: How do I add items to GWT ListBox in Uibinder .ui.xml template ?)
private class SimpleRenderer implements Renderer<T>{
private String emptyValue = "Select a value";
#Override
public String render(T val) {
if(val == null) {
return emptyValue;
}
return val.toString();
}
#Override
public void render(T val, Appendable appendable) throws IOException {
appendable.append(render(val));
}
public void setEmptyValue(String emptyValue) {
this.emptyValue = emptyValue;
}
}