I was wondering if Primefaces' carousel component can display other html elements
like <div>, <iframe> or even other html files?
Yes; carousel can display any type of content in it.
For example, imagine you have a managed bean (mybean) storing a list of page URLs (urls).
This would display an IFrame pointing to the URL in every cell:
<p:carousel value="#{mybean.urls}" var="url">
<iframe src="#{url}" width="300" height="300"></iframe>
</p:carousel>
Related
I want to get the current captcha that is displayed on a website. An example of this would be
http://top100arena.com/in.asp?id=58978
How would I get the image link of the captcha that is displayed other than right clicking - > open image in new page?
You are looking for the div identified by "rechapta_image":
Then extract the src attribute of the img element inside this div.
To do this, you can choose for an easy String-operation-based way or use a HTML parsing library like JSoup.
Here is an example of such an extract URL:
http://www.google.com/recaptcha/api/image?c=03AHJ_VutGj3wvhGoQGxu6FUnG3uOWJdyB2RpSb2N5v9AQJyakMy1kKMPeDoRfADhjAj5rLqekuOzXe3cRChnA_sEN7PL68em4pI_kE3wFKUhhkqFF9jQzKJerX__InwD_DB0Ox1mKQmZVRl97yuSL62tZhYyhSqtuIta-3n0KvytB9QqSn8nXgw8
Actually, it seems that the chapta box is an iframe. So search for an iframe with src string containing "chapta". Example of such a iframe:
<iframe src="http://www.google.com/recaptcha/api/noscriptk=6LeyFroSAAAAAJTmR7CLZ5an7pcsS5eJ3wEoWHhJ"
height="300" width="500" frameborder="0"></iframe><br/>
So, once you extracted that URL, use JSoup again to find the URL to the image. The page fetched has a part this:
So, look for a center element, and get the img element out of it.
Try using Firebug in firefox https://addons.mozilla.org/es/firefox/addon/firebug/, Its easy to use and in the Red section you´ll find a label named Image, you´ll find the image there.
I have a datatable with some items. The datatable has some css on the table tag. When I update the dataproviders model list and send the component back with ajax the css doesn't get rendered.
However if I send the entire page using ajax the table is rendered correct.
Example:
<wicket:panel>
<table class="striped">
</table>
</wicket:panel>
This css class gives odd and even a different css.
This is how I update the component after changing the dataprovider.
ajaxRequestTarget.add(MyPage.this.get("myPanel")); //this panel contains the table
The data gets added but the css markup is gone.
Refreshing the page brings back the css.
ajaxRequestTarget.add(MyPage.this); //send the entire page
This works but the entire page gets refreshed(and this make the page scroll up.
Whats the difference in component rendering if you send the entire page, instead of only 1 component/panel?
I'm using chrome.
If you render styles via jQuery, you'll have to call it again to re-paint correctly.
ajaxRequestTarget.appendJavascript("renderMethod('.striped');");
I have a main html page which contains an IFRAME.
I have a server side jsp code that is displayed with some default values inside the IFRAME for the first time.
Whenever a person tries to use a search button in the main page the results are displayed in the IFRAME updating its content.
I have a servlet that does the calculation on the searched data and updates the IFRAME content.
The problem:
I have used the sendRedirect method in servlet to refresh the IFRAME but to no avail.
The string I am passing to sendRedirect is /results.jsp?search=value&size=1 (jsp to be displayed in iframe).
The servlet does its calculation work properly but opens a new page in place of the mainpage: not a desired output.
The mainpage with its interface should remain there, only the IFRAME should refresh.
My question:
Is this the correct method to refresh an iframe? If not kindly tell me what should I use to update my iframe (jsp) via servlet.
PS: Please forgive the absurdity of the quesion if any. I am new to the jsp-servlet.
Any help is much appreciated
When you do a redirect using response.sendRedirect() method, the actual 'frame' where the servlet was called will be modified. That frame can be the entire page, or an iframe, or even the legacy frames used in javadocs.
As #Jake223 said, set the target attribute to the iframe name in the form:
If you are using a form to submit the information, then you do something like this:
<iframe name="resultframe"></iframe>
<form action=[path to servlet] target="resultframe">
<input type="text" name="searchq"/>
<input type="submit" value="search"/>
</form>
If you are using javascript to create the iframe, then use the src attribute of the iframe:
<iframe src=[path to servlet]?[request params]></iframe>
If the search mechanism is an HTML form, you can set the target attribute of the form to the name of the iframe in question. See W3Schools's page on this for more details.
In my webpage (Eg Link1: http://localhost:8086/MyStrutsApp/login.do) I have several links. When a user clicks on one of the links, he is taken to another page (Eg link2: http://localhost:8086/MyStrutsApp/AddBook.jsp) to fill an html form.
Now what I want to achieve is that when any user clicks on the link, that html form (Link2) is displayed on the same page (i.e. Link1).
I have no idea how to achieve this.
The AJAX way to achieve this is the following:
you have a DIV on your original page that will be replaced (i.e., either has content that only makes sense in the original context or completely empty)
your Link2 servlet produces only the contents of the above DIV (and not the contents of that page)
you use a tiny bit of Javascript to make an AJAX call and fill the DIV with the response.
If you want to use Dojo, the HTML page would look like this:
<!-- main content -->
<div id="leftpanel">
<h3>This content will be replaced</h3>
You can add a book
</div>
The Javascript code would look like this:
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js" type="text/javascript"></script>
<script type="text/javascript">
function display_wait(s) {
var mainPanel=dojo.byId("leftpanel");
mainPanel.innerHTML='<div class="waitingmsg">'+s+'</div>';
}
function updateFromURL(url) {
display_wait("loading content");
dojo.xhrGet({url:url,
load:function(result) {
dojo.byId('leftpanel').innerHTML=result;
}});
}
</script>
(As Rafa mentioned, you can use the same technique to display the new part in a dialog)
You can always use jQuery to present a dialog ... http://jqueryui.com/demos/dialog/
Retrieve the page with AJAX and present it inside the dialog.
To display one page within another, use an iframe. See the iframe docs.
To make a link on the outer page load its target page into the iframe, give the iframe a name attribute, and give the link a matching target attribute.
I'm trying to create a <a> tag in my Facelets XHTML page, but can't understand how to do it.. This is what I'm doing:
<h:outputLink value="static/faq.xhtml">FAQ</h:outputLink>
Am I using the right tag?
This should work. Open page in webbrowser, rightclick and View Source to see the JSF-generated HTML output. You should see a <a> element being generated.
To learn what HTML the JSF components are rendering, head to the tag documentation. Here's a cite of relevance of the one for <h:outputLink>:
Render an HTML "a" anchor element. The value of the component is rendered as the value of the "href" attribute.
Simply use FAQ.