You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Adam <ad...@softfab.com> on 2006/07/05 13:47:42 UTC

Hooking into the tree2 autoscrolling

Dear All,

We have an XForm + JSF combination where the is a JSF Tree2 of the left 
of the page & the XForm on the right.

Tree2 has it's own scrolling function built in in Javascript to set the 
position of the tree back to the point where you clicked on a TreeNode 
after a refresh.

e.g.:

<input name="autoScroll" type="hidden">



<script type="text/javascript"><!--
function getScrolling() {
     var x = 0; var y = 0;
     if (self.pageXOffset) {
         x = self.pageXOffset;
         y = self.pageYOffset;
     } else if (document.documentElement && 
document.documentElement.scrollLeft) {
         x = document.documentElement.scrollLeft;
         y = document.documentElement.scrollTop;
     } else if (document.body) {
         x = document.body.scrollLeft;
         y = document.body.scrollTop;
     }
     return x + "," + y;
}
window.scrollTo(0,1899);

//--></script>


This is great.....however obviously the XForm then is "trapped" at the 
top of the page & you then have to scroll back up to it. So we wrote a 
scrolling function for the XForm however.....if does not detect that the 
above piece of code has executed & thus stays at the top till you make 
any kind of movement of the scroller bar with your mouse & then it coems 
down the page to you.

This is fine & much better than scrolling however even nicer would be 
for the form & the tree to be in sync.

So my questions are:

(A) Does the above kick off any kind of event which I can listen out for?

I have already added a window scroll listener e.g.:

xAddEventListener(window, 'scroll', winOnScroll, false);

which is how it detects that a (mouse driven) scrolling event has 
occurred but the myfaces tree2 code does not appear to kick one of these 
off.

(B) Is there any way to get the vertical position out such that the 
position of the chosen node in the tree & the form can be aligned?


TIA

Adam


Re: autoscrolling

Posted by Mike Kienenberger <mk...@gmail.com>.
It looks like your extension filter configuration is wrong, which is
why the javascript methods aren't being added to the page.

The order of elements in a dtd xml file is fixed -- you cannot add
things out of order.

filter
filter-mapping
servlet
servlet-mapping

is the required order of the four elements you have above.   See the
dtd for the full description (just open the url attached to the dtd
file).


On 7/31/06, Jan Dockx <Ja...@peopleware.be> wrote:
>
> I'm trying to use autoscroll, but the described problem comes up:
> commandLinks do nothing because the getScrolling() JS method is not in the
> page. What is the actual status on autoscroll? I see in discussions that it
> is supposed to be fixed in 1.1.3.
>
> I am using the commandLinks in a h:form, they work with autoscroll = false.
> MyFaces API, Impl and Tomahawk are 1.1.3. ExtensionsFilter is defined in
> web.xml as
>
>   <servlet>
>     <servlet-name>FacesServlet</servlet-name>
>     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
>     <load-on-startup>1</load-on-startup>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>FacesServlet</servlet-name>
>     <url-pattern>/faces/*</url-pattern>
>   </servlet-mapping>
>
>   <filter>
>     <filter-name>extensionsFilter</filter-name>
>
> <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
>     <init-param>
>       <description>Set the size limit for uploaded files.
>         Format: 10 - 10 bytes
>         10k - 10 KB
>         10m - 10 MB
>         1g - 1 GB
>       </description>
>       <param-name>uploadMaxFileSize</param-name>
>       <param-value>100m</param-value>
>     </init-param>
>     <init-param>
>       <description>Set the threshold size - files
>         below this limit are stored in memory, files above
>         this limit are stored on disk.
>
>         Format: 10 - 10 bytes
>         10k - 10 KB
>         10m - 10 MB
>         1g - 1 GB
>       </description>
>       <param-name>uploadThresholdSize</param-name>
>       <param-value>100k</param-value>
>     </init-param>
>   </filter>
>
>   <filter-mapping>
>     <filter-name>extensionsFilter</filter-name>
>     <servlet-name>FacesServlet</servlet-name>
>   </filter-mapping>
>
>   <filter-mapping>
>     <filter-name>extensionsFilter</filter-name>
>
> <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
>   </filter-mapping>
>
> Funny thing: commandLink inside a tree2 works on the first page, but on the
> second page commandLinks do nothing in a tree2 nor a data table.
>
> I presume the ExtensionsFilter is setup correctly, because in the generated
> HTML of the problematic page I have
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"><head>
> <script type="text/javascript"
> src="/convenants/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11543838/tree2.HtmlTreeRenderer/javascript/tree.js"><!--
>
> //--></script>
> <script type="text/javascript"
> src="/convenants/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11543838/tree2.HtmlTreeRenderer/javascript/cookielib.js"><!--
>
> //--></script><title>
>
>
> at the top.
>
>
>
>
>
> Met vriendelijke groeten,
>
>
>
>
> Jan Dockx
>
> CTO
>
>
>
>
> PeopleWare NV - Head Office
>
> Cdt.Weynsstraat 85
>
> B-2660 Hoboken
>
> Tel: +32 3 448.33.38
>
> Fax: +32 3 448.32.66
>
>
>
>
> PeopleWare NV - Branch Office Geel
>
> Kleinhoefstraat 5
>
> B-2440 Geel
>
> Tel: +32 14 57.00.90
>
> Fax: +32 14 58.13.25
>
>
>
>
> http://www.peopleware.be/
>
> http://www.mobileware.be/
>

autoscrolling

Posted by Jan Dockx <Ja...@peopleware.be>.
I'm trying to use autoscroll, but the described problem comes up:  
commandLinks do nothing because the getScrolling() JS method is not  
in the page. What is the actual status on autoscroll? I see in  
discussions that it is supposed to be fixed in 1.1.3.

I am using the commandLinks in a h:form, they work with autoscroll =  
false. MyFaces API, Impl and Tomahawk are 1.1.3. ExtensionsFilter is  
defined in web.xml as

   <servlet>
     <servlet-name>FacesServlet</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
     <servlet-name>FacesServlet</servlet-name>
     <url-pattern>/faces/*</url-pattern>
   </servlet-mapping>

   <filter>
     <filter-name>extensionsFilter</filter-name>
     <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</ 
filter-class>
     <init-param>
       <description>Set the size limit for uploaded files.
         Format: 10 - 10 bytes
         10k - 10 KB
         10m - 10 MB
         1g - 1 GB
       </description>
       <param-name>uploadMaxFileSize</param-name>
       <param-value>100m</param-value>
     </init-param>
     <init-param>
       <description>Set the threshold size - files
         below this limit are stored in memory, files above
         this limit are stored on disk.

         Format: 10 - 10 bytes
         10k - 10 KB
         10m - 10 MB
         1g - 1 GB
       </description>
       <param-name>uploadThresholdSize</param-name>
       <param-value>100k</param-value>
     </init-param>
   </filter>

   <filter-mapping>
     <filter-name>extensionsFilter</filter-name>
     <servlet-name>FacesServlet</servlet-name>
   </filter-mapping>

   <filter-mapping>
     <filter-name>extensionsFilter</filter-name>
     <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
   </filter-mapping>

Funny thing: commandLink inside a tree2 works on the first page, but  
on the second page commandLinks do nothing in a tree2 nor a data table.

I presume the ExtensionsFilter is setup correctly, because in the  
generated HTML of the problematic page I have

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"><head>
<script type="text/javascript" src="/convenants/faces/ 
myFacesExtensionResource/ 
org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11543838/ 
tree2.HtmlTreeRenderer/javascript/tree.js"><!--

//--></script>
<script type="text/javascript" src="/convenants/faces/ 
myFacesExtensionResource/ 
org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11543838/ 
tree2.HtmlTreeRenderer/javascript/cookielib.js"><!--

//--></script><title>


at the top.



Met vriendelijke groeten,

Jan Dockx
CTO

PeopleWare NV - Head Office
Cdt.Weynsstraat 85
B-2660 Hoboken
Tel: +32 3 448.33.38
Fax: +32 3 448.32.66

PeopleWare NV - Branch Office Geel
Kleinhoefstraat 5
B-2440 Geel
Tel: +32 14 57.00.90
Fax: +32 14 58.13.25

http://www.peopleware.be/
http://www.mobileware.be/


Re: Hooking into the tree2 autoscrolling

Posted by Adam <ad...@softfab.com>.
Adam wrote:

Never mind, I hooked the form scrolling code into the onload event & 
alles ist gut.


Adam

> Dear All,
> 
> We have an XForm + JSF combination where the is a JSF Tree2 of the left 
> of the page & the XForm on the right.
> 
> Tree2 has it's own scrolling function built in in Javascript to set the 
> position of the tree back to the point where you clicked on a TreeNode 
> after a refresh.
> 
> e.g.:
> 
> <input name="autoScroll" type="hidden">
> 
> 
> 
> <script type="text/javascript"><!--
> function getScrolling() {
>     var x = 0; var y = 0;
>     if (self.pageXOffset) {
>         x = self.pageXOffset;
>         y = self.pageYOffset;
>     } else if (document.documentElement && 
> document.documentElement.scrollLeft) {
>         x = document.documentElement.scrollLeft;
>         y = document.documentElement.scrollTop;
>     } else if (document.body) {
>         x = document.body.scrollLeft;
>         y = document.body.scrollTop;
>     }
>     return x + "," + y;
> }
> window.scrollTo(0,1899);
> 
> //--></script>
> 
> 
> This is great.....however obviously the XForm then is "trapped" at the 
> top of the page & you then have to scroll back up to it. So we wrote a 
> scrolling function for the XForm however.....if does not detect that the 
> above piece of code has executed & thus stays at the top till you make 
> any kind of movement of the scroller bar with your mouse & then it coems 
> down the page to you.
> 
> This is fine & much better than scrolling however even nicer would be 
> for the form & the tree to be in sync.
> 
> So my questions are:
> 
> (A) Does the above kick off any kind of event which I can listen out for?
> 
> I have already added a window scroll listener e.g.:
> 
> xAddEventListener(window, 'scroll', winOnScroll, false);
> 
> which is how it detects that a (mouse driven) scrolling event has 
> occurred but the myfaces tree2 code does not appear to kick one of these 
> off.
> 
> (B) Is there any way to get the vertical position out such that the 
> position of the chosen node in the tree & the form can be aligned?
> 
> 
> TIA
> 
> Adam
> 
>