passing text from an Array to UIWebView - iphone

i want to pass some html i have saved as string and stored in an array into a UIWebView.
can anyone help me on how to do this because all i can find is how to grab it from the internet rather than already stored data
Thanks

Are you trying to provide generated HTML content to a UIWebView? If so, you'll want to use -[UIWebView loadHTMLString:baseURL:]. You can pass your HTML string for the first argument, and nil in for the second argument.

Related

how to pass values from a jquerymobile page to a .m file

I have a series of form pages in my iphone app.
When the user completes the form and submits it the code needs to collate the form data and embed it into a predefined string.
Once the string has been created using the form values, i need to then pass that string so that it can be read by a .m file, for processing.
Can anyone please advise how i go about this ??
Please note I am a newbie to iphone app development
Simply post your form using an hidden field that contains your string
or use changePage with data argument:
$.mobile.changePage( "../resources/results.php", {
type: "post",
data: $( "form#yourId" ).serialize(),
changeHash: false
});

Print the particular GWT widget

I'm trying to print a GWT widget as follows,
String html = DOM.getElementById("id").getInnerHTML();
Print.it(html);
I'm not getting the entire html content of the widget. So i'm not able to print the expected result.
Can you help me? Or tell me the alternative way of printing a particular GWT widget from the view.
Thanks in advance,
Gnik
Well, it should print the HTML code. Calling DOM statically may generate 2 problems for you:
The ID you are trying to use isn't the right one. There is another element with the same ID and you are retrieving the element for that ID.
The ID you are using doesn't exist, as a framework may be changing this ID.
You can try to retrieve the HTML code with this widget.asWidget().getElement().getInnerHTML();
That should give you the correct HTML representation of the widget.
And make sure you are calling those methods after the elements are loaded (onLoad()) into the document, or you may recieve a JavaScriptException due to the element being null (check here for more info).

Is it possible to pass post data to the form (prefill form with data)?

For example https://stackoverflow.com/questions/ask there we have form id="post-form" which has method="post", is it possible somehow open this form and have lets say Name input (display-name) with my name prefilled on load?
Yes. You can do this many ways, with Javascript by setting the input's text, or you can do it server-side with PHP by echoing "value=\"$name\"" for the value attribute of the input.

How to modify a <staticText> element in a JasperReport

I've an xml that I restore from my Data base containing jasperreports. Here's an excerpt:
<staticText>......<text><![CDATA[Entidad Bancaria:]]></text></staticText>
I want to programatically substitute the content of the CDATA element and then regenerate the JasperReport, but I found that the API doesn't allow to do this (or it's too difficult to figure out how). So I tried to convert the jasper xml into a string, from string to Inputstream (to match the signature of JasperFillManager.fillReport() method), but the compile fails... Does anyone know how to accomplish this in a correct way?
Thanks!
Static text isn't made to be changed programmatically. Why not just change the staticText to a textField and then use a parameter? Change the xml to:
<textField><textFieldExpression><![CDATA[$P{banc}]]></textFieldExpression></textField>
Then set the value of banc programatically and pass it to fillReport()

How to use unescape() function inside JavaScript?

I have a JSP page in which I have JavaScript function that will be called when a link is clicked. Now, when the value reaches the JavaScript function, the apostrophe is encoded.
Example:
Name#039;s
Before # there is &, which originally should be:
Name's
I have used the unescape() decode function, but nothing seems to work. In the end, I had to delete the characters and add the apostrophe. Does anyone know a fix for this? Is it that JSP doesn't support encoding for &? When I was writing the same encode value in this page, it changed the symbol to the apostrophe, which is what I wanted in my code.
Built-in Javascript function such as unescape(), decodeURIComponent() has nothing to do with the string you are working on, because the one you are looking to decode are HTML entites.
There are no HTML entites decoder available in Javascript, but since you are working with a browser, if the string is considered safe, you may do the following (in JQuery, for example)
var str = $('<p />').html(str).text();
It bascially insert the string as HTML to a <p> element and then extract the text within.
Edit: I just realize the JSP output you posted is not real HTML entities; To process the example given you should use the following, add & before every #1234; and make it Ӓ:
var str = $('<p />').html(str.replace(/\#(\d+)\;/g '&#$1;')).text();