Fix header during scroll - java

I am working on this website, and as you can see I have a different header for different pages. In the other pages the header, the navigation, and the logo are fixed on top during scroll but not in this page.
Is possible to fix them in this page as well via JS?

You have to set the class of your dslc-header element to dslc-header-pos-fixed
<div id="dslc-header" class="dslc-header-pos-relative">
to
<div id="dslc-header" class="dslc-header-pos-fixed">

Related

Load Instagram images by scrolling down to bottom of page

Taking this instagram link for eg. https://www.instagram.com/janelaverdegarden/, I want to load all the images by scrolling to the bottom of the page. To do that, I have to click LOAD MORE button, scroll down to bottom page, wait for page to load, scroll up abit, and scroll down to bottom page and wait for page to load again till no more images are left (manually).
However, I want to load the page automatically using Selenium. Thus, initially, I thought that once the page is fully loaded to the end of the page with all the images, the web element rbSensor will disappear, allowing me to mark that the page has reached the bottom with no more images to be loaded. However, it still remains there. So is there any other way to check if the page is fully loaded with all the images?
<div data-reactid=".0.1.0.1:$mostRecentSection/=10">
<div class="_nljxa" data-reactid=".0.1.0.1:$mostRecentSection/=10.0">
<div class="ResponsiveBlock" data-reactid=".0.1.0.1:$mostRecentSection/=10.1">
<div class="rbSensor" data-reactid=".0.1.0.1:$mostRecentSection/=10.1.$sensor">
<iframe class="rbSensorFrame" data-reactid=".0.1.0.1:$mostRecentSection/=10.1.$sensor.0"/>
</div>
</div>
</div>
Code. As I used rbSensor to load the page, even if the page is fully loaded with all the images, the element will still be clicked continuously as the element is still in the html.
while (driver.findElements(By.className("rbSensor")).size() > 0) {
jse.executeScript("window.scrollTo(0,-300)"); //scroll up abit
//click on button if found
driver.findElement(By.className("rbSensor")).click();
Thread.sleep(2000); //pause for 2 seconds
}
Using the answer below in Page scroll up or down in Selenium WebDriver (Selenium 2) using java is not what I want and will not work in this case.
jse.executeScript("window.scrollBy(0,250)", "");
Try using a different class name
className("_oidfu")
has href attribute
Scrolling answer can be found here: Page scroll up or down in Selenium WebDriver (Selenium 2) using java

Wicket Table css not rendered after ajax update?

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');");

Find html markup tags by their id wicket

I have this table column which sometimes needs to be hidden..
<td id="row1"><span wicket:id="state">Servicio de Reprografia</span></td>
Is it possible for me to find this somehow through java code and add a hidden attribute in order to completely hide this markup?
You will need to use <wicket:enclosure> to hide the surrounding markup when the wicket component is hidden:
<wicket:enclosure>
<td id="row1"><span wicket:id="state">Servicio de Reprografia</span></td>
</wicket:enclosure>
state.setVisible(false);
target.addComponent(state);
I suppose you want to do this in an onClick() or onSubmit() handler of one of your components on the page. In this case, you have to call:
getPage().get("path:to:component").setVisibleAllowed(false);
Furthermore, if you do this within an AJAX callback, you have to add the (now hidden) component to the AjaxRequestTarget.
path.to.component corresponds to the nesting of your wicket components. This will allow you to hide the <span> element. If you want to hide the <td>, too, I'd advise to move your wicket:id tag to the <td>element.

primefaces - Can carousel display other content aside from images?

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>

Display page data on same page without forwarding it to another page

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.

Categories

Resources