I have a Dialog that retrieve informations from an endpoint (String of information) but I have a Problem with style this dialog, because all these informations appear untidily!
For example to be clear, I have this endpoint, that it helps me to retrieve a Data about Mobile, and want to show this Data in a Dialog (BUT the Style should like Screenshot Nr. 1), but my Problem is that the data appears as Preview (Screenshot 2).
You can use the Html component with a pre tag where you put the formatted JSON:
Html pre = new Html("<pre>" + formattedJson + "</pre>");
To format the JSON String you can use this:
String prettyJson = mapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(mapper.readTree(inputJson));
Find more examples here: https://roytuts.com/how-to-pretty-print-json-in-java/
Related
I know it's possible to display a Google Sheet as HTML using the spreadsheet ID and GID, i.e.:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/gviz/tq?tqx=out:html&tq&gid=GID
But in order to view that, you have to know the URL of the sheet. What I'm wondering is whether it's possible to display this HTML version of the sheet but without revealing the URL of the sheet?
Manually
To retrieve a Spreadsheet in HTML format you can export it accordingly by clicking on File -> Download -> Web Page. That will get you a zip file with the HTML of your Spreadsheet that you can rename as you like without revealing the Spreadsheet ID.
With Apps Script
You can also automate this process creating an Apps Script function that for instance gets triggered every time you click on an inserted button (to do this you can simply click on the menu bar Insert -> Drawing and the on the three dots of the top right of this button click on assign script and set it to the name of your function).
The following function will display a modal dialog on the Spreadsheet when run that if the user clicks on Download it will automatically download the zip file with the Spreadsheet in HMTL format. This function has self explanatory comments :
function downloadHTML() {
// Get ID of the Spreadsheet
var id = SpreadsheetApp.getActive().getId();
// Get the download URL of this Spreadshet in format HTML on the background
var url = "https://docs.google.com/a/mydomain.org/spreadsheets/d/" + id + "/export?exportFormat=zip&access_token=" + ScriptApp.getOAuthToken();
// Download when clicked on the button of the opened dialog
var html = '<input type="button" value="Download" onClick="location.href=\'' + url + '\'" >';
// create an HTML output from the given string
var dialog = HtmlService.createHtmlOutput(html);
// Show a modal dialog on the Spreadsheet UI when the function is run with the Title download
SpreadsheetApp.getUi().showModalDialog(dialog, "Download");
}
Reference
createHTMLOutput
showModalDialog
Is there any way I can grab only the title, author, date, and text from a Wordpress website's article through its RSS feed? I'm trying to create an iOS app (Xcode) that can display this information.
EDIT:
I am currently using rshankras' BlogReader code to fetch articles from the website, but it displays the actual link to the page. I'm looking to be able to access the article's title, author, date, and text, and be able to format it myself, instead of having the actual site show up. What tools can I use to do this, if feasible?
This is the website in question.
You are using a ready-made app so I think, you will have to modify it yourself to serve your purpose. For showing content as you want, you need to manipulate the HTML content instead of viewing it in WebView.
Inside your app, the WebView element is in PostViewController.swift file. So if your put the following code in line number 24 of that file, you will get the URL that is being requested.
println(url)
This code prints the output in console. Now as you know the url. You can simply fetch the HTML Code and manipulate and show it as your heart want using the following way:
let pageurl = NSURL(string: url) //you got the url variable 3 lines above
let task = NSURLSession.sharedSession().dataTaskWithURL(pageurl!) {
(data, response, errror) in
if error == nil {
var urlContent = NSString(data: data, encoding: NSUTF8StringEncoding) as NSString!
println(urlContent)
}
}
This will print the full HTML Code string encoded using UTF-8.
Now in the postViewController, instead of using WebView element, you can use a label, or textbox or whatever you want to show your content inside. Then create an outlet for that element. And then manipulate the HTML Code String by following way:
var urlContentArray = urlContent?.componentSeparatedByString("<span class=\"storybyline\">") // In your website (vikinglogue.com) your author name is inside this span element.
println(urlContentArray[1]) // This will print everything after that span section in your console
var authorArray = urlContentArray[1].componentSeparatedByString("</span>")
var author = authorArray[0]
Now you have the author name and you can show it in any textbox or label or in any element that support text. You can grab all other info from that page in the same way. I hope it helped.
Since RSS comes in a structured XML format, you can simply fetch your page's rss feed and parse the elements for the needed data. To see some how to code, you may check out mwaterfalls' Feedparser
e.g
<title>Girls softball dominating early</title>
<link>
http://vikinglogue.com/2377/sports/girls-softball-dominating-early/
</link>
<comments>
http://vikinglogue.com/2377/sports/girls-softball-dominating-early/#comments
</comments>
<pubDate>Wed, 22 Apr 2015 21:54:32 +0000</pubDate>
I am trying to set tooltip (mouse over info) on Acroforms fields using itext. I have no issues with Textfields, Checkboxes and Listfields. But for some reason the tooltip is not getting shown in case of RadioCheckField. Following is the code snippet
RadioCheckField radio = new RadioCheckField(writer, new Rectangle(x, y - 4, x + 14, y - 14), name, exportValue);
PdfFormField field = radio.getRadioField();
field.setUserName(toolTip);
field.setName(name);
writer.addAnnotation(field);
radiogroup.addKid(field);
Invoking setUserName on PdfFormField sets the /TU flag in PDF. When I examined the generated PDF through Rups, I can see that /TU is set for RadioCheckField kids in the radioGroup. But still no tooltip is shown. For 508 (accessibility) compliance tooltip functionality is a must.
Here is a link to PDF file generated from above code http://www.docdroid.net/14son/output.pdf.html
Can anybody provide some information?
I am using the following code in the fusion tables 'customize info window' to create hyperlinked URL's from a column in my table:
"{URL}"
This works fine in returning the clickable hyperlink in the info box except fusion maps by default tacks on https: instead of http: when the link is clicked. This causes problems when the user clicks the hyperlink and it tries to take them to a secure site when in fact it is not secure. The browsers throw up all sorts of warnings that will scare the pants off a lot of users who don't know what is happening.
Does anybody know how to remedy this and have the default be http and not the current https?
Thanks, Shep
You may want to abandon the "{URL}" approach and display the hyperlink with some simple HTML. This example from Google shows how to modify the info window's HTML in Javascript:
google.maps.event.addListener(layer, 'click', function(e) {
// Change the content of the InfoWindow
e.infoWindowHtml = e.row['Store Name'].value + "<br>";
// If the delivery == yes, add content to the window
if (e.row['delivery'].value == 'yes') {
e.infoWindowHtml += "Delivers!";
}
});
Changing the e.row['Store Name'] to your URL column name (maybe, e.row['URL']) and surrounding by a couple of hyperlink tags <a> should do the trick:
e.infoWindowHtml = "<a href='" + e.row['URL'].value + "'>Click here!</a>";
There are three ways:
Specify a full URL including protocol in your data
Use Link here in a custom info window layout
Completely override the content as in the answer above
I would recommend #1 because you can choose the right protocol for every link. However #2 is probably easier in that you can leave your data the way it is.
From the Worklight tutorial - 05_05_Enabling_translation.pdf (Sample app), we can
1. Define the translated message in messages.js
2. Reference the message in HTML as the ID of an HTML element with class="translate" or as a JavaScript object property Messages.<ID>.
3. Implement a languageChanged function to set a new value of Messages.<ID> and update the content to selected language.
In the example - languageChanged(lang) function:
$("#sampleText").html(Messages.sampleText);
$("#headerText").html(Messages.headerText);
$("#actionsLabel").html(Messages.actionsLabel);
is used to update the content to selected language.
From my understanding, it is required to write the above line of codes to update the content to selected language.
Is there a better way to update the content if there are lots of elements?
You can easily iterate over all elements by using jQuery selectors and update text, e.g. something like
$(".translate").each(function(index, element){
element = $(element);
var elementId = element.attr("id");
element.text(Messages[elementId]);
});