Apache Wicket how to render a (non-wicket) response page - apache

I'm using Apache Wicket and I have following problem:
Inside a onSubmit() method I am sending a POST request to external web address with Apache httpClient. As a response I get html (inside my response object).
How can I get Wicket to render this html in browser?
So basically what I'm trying to do here, is simply what would normally happen if I submitted a html form to this web address. However for security reasons I don't want to give user pages containing forms that contain this data I'm trying to send.

You can get the response via getResponse() in any component. (I assume the onSubmit() is on a form).
How about something like:
getResponse().reset();
getResponse().write(htmlPage);
htmlPage should be a CharSequence containing the html page to be rendered.

Related

Sitecore Web API GetRenderingHtml response message

I have a requirement of getting HTML output for a component in a page.
I get a response message "Preview is unavailable for the Default rendering." when I try to use GetRenderingHTML Web API.
My API call looks like : http://<HostName>/-/item/v1/-/actions/GetRenderingHtml?database=master&language=en-US&renderingId=<RENDERING_ID>&itemId=<ITEM_ID>
There are couple things you need to consider while using GetRenderingHtml action.
GetRenderingHtml does not return output of a component on a page. The itemId parameter is used to find a datasource for your component, not a page which uses a component.
It only allows method redering, sublayout, url rendering, xsl rendering, webcontrol and xmlcontrol to be rendered.
The fact that your message says for the Default rendering means that whatever id you passed as renderingId, there is an item in your database with this id and DisplayName property set to Default and this item is not a rendering listed in point 2.

How do I display an image returned from MVC4 Web API

We have a Web API (MVC4) application that returns images from the database. I have verified that the call to the Web API does produce a valid image.
Here is the Fiddler result showing that the image is returned properly: :
I tried setting an image element with the same source as the call, but that didn't work:
<img id="img" src="http://localhost/Seek/api/artifactcontent/?userName=XXXXX&password=XXXXXX&id=15-00931-27" />
What am I doing wrong?
You request in Fiddler is a POST request; the <img> tag sends a GET request. If you want to display images using <img> tags, you'll need to make your action accept GET requests instead of (or in addition to) POST.

Get the HTML output data from a wicket component

I'm currently writing a web widget, and I would like to fill the content of this widget with some HTML data generated by a wicket component on my server.
To do that, the server will output the HTML data via JSONP. So far so good.
However I need to get this HTML data. How can I get on the server the HTML output from some wicket component?
I dont know if this can be applied to your configuration, but I am using a view lines of code to retrieve rendered html which I wrote some time ago for building html based emails to be able to use wicket components in it
protected final String renderPage(Component page) {
final Response oldResponse = RequestCycle.get().getResponse();
BufferedWebResponse tempResponse = new BufferedWebResponse((WebResponse) RequestCycle.get().getOriginalResponse());
try {
RequestCycle.get().setResponse(tempResponse);
page.render();
}
finally {
RequestCycle.get().setResponse(oldResponse);
}
return tempResponse.toString();
}
As this rendering is made within an actual webapplication cycle but independently from the actual requestcycle, it is recommended to preserve the original requestcycle. The page will be rendered in your temporary webresponse from which you can retrieve the rendered html output.
Hope this may be what you are looking for
You might find everything you need in this Wicket Wiki article and the linked source code: Use wicket as template engine
Although I must admit that I never tried that, just read it and remembered for further reference...

scrape the reponse which would be loaded from ajax event

I am using scrapy tool to scrape content from website, i need help from you guys how to scrape the reponse which is dynamically loaded from ajax.
when content loading from ajax at that mean time url not changing it keep remains same but content would be changed so on that event i need to crawl.
thank you,
G.kavirajan
yield FormRequest('http://addons.prestashop.com/en/modules/featureproduct/ajax-homefeatured.php',
formdata={'type':'new','ajax':'1'},
callback=self.your_callback_method)
bellow are the urls that you can easily catch using fiddler or firebug
this is for featured tab http://addons.prestashop.com/en/modules/featureproduct/ajax-homefeatured.php?ajax=1&type=random
this is for new tab http://addons.prestashop.com/en/modules/featureproduct/ajax-homefeatured.php?ajax=1&type=new
you can request on these url directly to get results you required, although website is using POST request to get data for these url, but i tried with parameter GET request is also working properly

How do we call a jsp page from VB page?

I have created a JSP page, which will accept parameter. Once the page received the parameter, it will return an XML to user.
I want to create a VB program, that will display a form and ask user to enter the value of the parameter, and then will pass it to the JSP page, and get the return XML and display it to user in VB program.
Is it possible to do so?
Thx
Use the HttpRequest class to request a web page. Then just manipulate the URL to add query string parameters. If you need to do this via a POST request (versus GET), write the parameters in the body.