ScrollPosition |
||||
Developer’s Guide Home
Installation and Configuration Common Concepts Components Index Border Layout Panel Calendar Chart Command Button Command Link Composite Filter Confirmation Data Table Date Chooser Day Table Drop Down Field Dynamic Image Folding Panel For Each Graphic Text Hint Label Input Text Input Textarea Layered Pane Level Indicator Popup Layer Popup Menu Select Boolean Checkbox Select Many Checkbox Select One Radio Spinner Suggestion Field Tabbed Pane Tab Set Tree Table Two List Selection Window Focus Load Bundle Scroll Position Ajax Framework Validation Framework Tag Reference API Reference |
Specifying Scroll Position ComponentTo add the ScrollPosition component on the page, use the <o:scrollPosition> tag. When this component is added, the scroll position is saved automatically. The ScrollPosition component has a boolean autoSaveScrollPos attribute. By default, it is set to "true", which means that the scroll position is saved between page submissions. <h:form>
<o:scrollPosition autoSaveScrollPos="true"/>
</h:form>
Specifying Scroll Position on Page LoadYou can specify the page's scroll position using the value attribute that should be bound to a variable of type java.awt.Point. The value referred to by this attribute should should specify coordinates of the top left corner of a page's visible area. <h:form>
<o:scrollPosition value="#{ScrollingBean.scrollPos}"/>
</h:form>
If the autoSaveScrollPos attribute is set to "true" (the default value), the scroll position is saved into the value attribute binding between page submissions. Specifying Scroll Position For the Scrollable ComponentYou can specify the identifier of the scrollable component by using the for attribute, the scroll position of the scrollable component will be saved between page submissions. If the for attribute is not specified – the scroll position of the page will be saved between page submissions. The for attribute should be assigned with the id of a JSF component or id of any HTML element, whose scroll position should be controlled:
Here is an example of tracking scroll position for an HTML element by its identifier: <h:form> <o:scrollPosition for=":scrollable_div"/> <div id="scrollable_div"> </div> </h:form> Note that if the value attributes is used with the for attribute then the appropriate coordinates will be applied to the specified scrollable component. Tracking Scroll Position For the Entire ApplicationYou can also set the org.openfaces.autoSaveScrollPos context attribute in web.xml to "true" (the default is "false") to track the scroll position for all application pages. <context-param>
<param-name>org.openfaces.autoSaveScrollPos</param-name>
<param-value>true</param-value>
</context-param>
|
|||
© 2010 TeamDev Ltd. | ![]() |