-
-
2. Re: <rich:datascroller>:
nbelaevski Oct 25, 2009 2:21 PM (in response to thomasgo)Hi,
This message means that there is not enough data for two pages, model provides data just for one. -
3. Re: <rich:datascroller>:
thomasgo Oct 25, 2009 2:30 PM (in response to thomasgo)Well, that's strange, but maybe I mistunderstood something.
The dataScroller is set as the footer facet of a dataGrid that is set to have 8 elements (4 columns x 2 rows). The list contains more than those 8 elements and thus the dataScroller displays controls for pages 1 and 2. But it won't open page 2.
Did I reduce the number of reachable elements to 8 when setting elements="8" in the dataGrid? -
4. Re: <rich:datascroller>:
nbelaevski Oct 25, 2009 2:48 PM (in response to thomasgo)Does the list contain more than 8 elements on subsequent request also?
-
5. Re: <rich:datascroller>:
thomasgo Oct 25, 2009 4:05 PM (in response to thomasgo)Yes, the list is loaded once, when the getter is first invoked.
There's not setter, so unless the framework doesn't do anything unexpected the list should not change after loading.
I checked it and the getter always returns 13 entries. -
6. Re: <rich:datascroller>:
nbelaevski Oct 25, 2009 4:16 PM (in response to thomasgo)I've tried this and it works ok. I guess your bean is request-scoped, is it so?
-
7. Re: <rich:datascroller>:
thomasgo Oct 25, 2009 4:36 PM (in response to thomasgo)No, the bean is session scoped.
-
8. Re: <rich:datascroller>:
nbelaevski Oct 25, 2009 4:39 PM (in response to thomasgo)Please post page and bean code.
-
9. Re: <rich:datascroller>:
thomasgo Oct 25, 2009 5:29 PM (in response to thomasgo)Here's the page:
<?xml version="1.0" encoding="iso-8859-1"?> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <rich:modalPanel id="selectImageDialog" autosized="true" width="500" moveable="true" style="background-color:#F8F8F8"> <h:form> <rich:panel id="selectImagePanel" style="max-height: 500px; overflow:scroll"> <a4j:repeat value="#{imageBean.categories}" var="category"> <rich:simpleTogglePanel label="#{category.name}" switchType="ajax" opened="#{category.opened}" reRender="selectImagePanel" limitToList="true" ajaxSingle="true" height="300"> <rich:dataGrid id="imageGrid" value="#{category.images}" var="image" columns="4" elements="8"> <h:panelGrid columns="1"> <rich:panel style="width: 110px; height: 110px; padding-top: 10px; text-align: center;"> <h:graphicImage title="#{image.name}" value="#{image.thumbnailPath}" style="max-width: 100px; max-height: 100px;" /> </rich:panel> <h:outputText value="#{image.name}"/> </h:panelGrid> <f:facet name="footer"> <rich:datascroller ajaxSingle="true" reRender="selectImagePanel" limitToList="true" stepControls="auto" for="imageGrid"/> </f:facet> </rich:dataGrid> </rich:simpleTogglePanel> </a4j:repeat> <a4j:commandLink value="#{appBundle.Cancel}" styleClass="button" onclick="Richfaces.hideModalPanel('selectImageDialog')" /> </rich:panel> </h:form> </rich:modalPanel> </ui:composition>
And the Bean:package de.itinformatik.wmf.interpraesent.presentation.administration.image; import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; public class ImageBean { private List<ImageCategoryUI> categories; /** * @return the categories */ public List<ImageCategoryUI> getCategories() { if( categories == null ) { reloadCategories(); } return categories; } /** * */ public void reloadCategories() { System.out.println( "reloading image categories" ); FacesContext tFacesContext = FacesContext.getCurrentInstance(); ExternalContext tExternalContext = tFacesContext.getExternalContext(); Set<String> tResourcePaths = new TreeSet<String>( tExternalContext .getResourcePaths( ImageCategoryUI.BASE_PATH ) ); categories = new LinkedList<ImageCategoryUI>(); if( tResourcePaths != null ) { for( String tResourcePath : tResourcePaths ) { if( tResourcePath.endsWith( "/" ) ) { tResourcePath = tResourcePath.substring( 0, tResourcePath.length() - 1 ); ImageCategoryUI tCategory = new ImageCategoryUI(); int tIndex = tResourcePath.lastIndexOf( '/' ); tCategory.setName( tIndex != -1 ? tResourcePath.substring( tIndex + 1 ) : tResourcePath ); System.out.println( "adding category " + tCategory.getName() + "(" + tResourcePath + ")" ); categories.add( tCategory ); } } } } /** * */ public String getThumbnailPath(String pImagePath) { System.out.println("getting thumbnail path for: " + pImagePath); return pImagePath; } /** * */ public String getMediumPath(String pImagePath) { System.out.println("getting medium path for: " + pImagePath); return pImagePath; } }
Finally, ImageCategoryUI:package de.itinformatik.wmf.interpraesent.presentation.administration.image; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class ImageCategoryUI { private static Log LOG = LogFactory.getLog( ImageCategoryUI.class ); public static final String BASE_PATH = "/images/categories"; private String name; private String opened = "false"; private List<ImageInfoUI> images; /** * @return the name */ public String getName() { return name; } /** * @param pName the name to set */ public void setName( String pName ) { name = pName; } /** * @return the opened */ public String getOpened() { return opened; } /** * @param pOpened the opened to set */ public void setOpened( String pOpened ) { opened = pOpened; } public List<ImageInfoUI> getImages() { if( images == null ) { reloadImages(); } System.out.println("num images: " + images.size()); return images; } public void reloadImages() { LOG.debug( "loading images for " + name ); FacesContext tFacesContext = FacesContext.getCurrentInstance(); ExternalContext tExternalContext = tFacesContext.getExternalContext(); Set<String> tResourcePaths = new TreeSet<String>(tExternalContext.getResourcePaths( BASE_PATH + "/" + name )); images = new LinkedList<ImageInfoUI>(); Map<String, ImageInfoUI> tImageMap = new LinkedHashMap<String, ImageInfoUI>(); if( tResourcePaths != null ) { for( String tResourcePath : tResourcePaths ) { if( !tResourcePath.endsWith( "/" ) ) { String tExtension = ""; String tSizeSuffix = ""; String tFilename = ""; int tLastDotIndex = tResourcePath.lastIndexOf( '.' ); if( tLastDotIndex != -1 ) { tExtension = tResourcePath.substring( tLastDotIndex ); } else { // if no dot was found set the index to the position after the last character // this is used for later calculations tLastDotIndex = tResourcePath.length(); } int tLastDashIndex = tResourcePath.lastIndexOf( '-', tLastDotIndex ); if( tLastDashIndex != -1 ) { tSizeSuffix = tResourcePath.substring( tLastDashIndex + 1, tLastDotIndex ); } else { // if no dot was found set the index to the position of the last dot // this is used for later calculations tLastDashIndex = tLastDotIndex; } // determine the size ImageSize tImageSize = null; try { tImageSize = ImageSize.valueOf( tSizeSuffix.toUpperCase() ); } catch( IllegalArgumentException iae ) { // if the size suffix isn't valid, don't cut it from the filename tLastDashIndex = tLastDotIndex; } int tLastSlashIndex = tResourcePath.lastIndexOf( '/' ); if( tLastSlashIndex != -1 ) { tFilename = tResourcePath.substring( tLastSlashIndex + 1, tLastDashIndex ); } else { tFilename = tResourcePath.substring( 0, tLastDashIndex ); } // get or create the image info ImageInfoUI tImageInfo = tImageMap.get( tFilename ); if( tImageInfo == null ) { tImageInfo = new ImageInfoUI(); tImageInfo.setExtension( tExtension ); tImageInfo.setFilename( tFilename ); tImageInfo.setCategory( this ); tImageMap.put( tFilename, tImageInfo ); } if( tImageSize != null ) { // set the size suffix switch( tImageSize ) { case SMALL: { tImageInfo.setSmallSuffix( '-' + tSizeSuffix ); break; } case MEDIUM: { tImageInfo.setMediumSuffix( '-' + tSizeSuffix ); break; } case LARGE: { tImageInfo.setLargeSuffix( '-' + tSizeSuffix ); break; } } } } } } images = new ArrayList<ImageInfoUI>(tImageMap.values()); } }
-
10. Re: <rich:datascroller>:
thomasgo Oct 27, 2009 6:22 AM (in response to thomasgo)Any new insights yet?
-
11. Re: <rich:datascroller>:
nbelaevski Oct 27, 2009 6:34 AM (in response to thomasgo)rich:datascroller doesn't work for nested iteration components. In your case you have rich:dataGrid inside a4j:repeat.
-
12. Re: <rich:datascroller>:
thomasgo Oct 27, 2009 2:38 PM (in response to thomasgo)So there's no way to get that working with a datascroller?
-
13. Re: <rich:datascroller>:
nbelaevski Oct 27, 2009 8:48 PM (in response to thomasgo)Unfortunately no way for now.
-
14. Re: <rich:datascroller>:
thomasgo Oct 28, 2009 3:27 AM (in response to thomasgo)OK, thanks for your help. Is there already a JIRA issue for this? If not, I'd create one.