You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Catalin Kormos <ca...@yahoo.com> on 2004/11/15 09:46:12 UTC

Tag dataTable and dataScroller usage

Hi,

I'm using myfaces-1.0.7, and i'm trying to implement a
table model backend bean to be able to control the
displayed page for table. The first time the table is
rendered i can set the "first" attribute to a specific
row index so it displayes the page content i want; but
then when i change de current page using the data
scroller, this does't change the "first" attribute
value of the table; so it can't find out which page
was selected by the user...there are some attributes
for dataScroller tag which seem to be very useful,
like the "pageIndexVar" attribute, but i have tryied
using it, and i always get a null value for it. Is
there someone  else who tryied using the value of
those attributes? Are these attributes used to specify
between requests which page was selected by the user?
how can these "var" attributes used? 

More exactly, is there a preferred way to control the
selected page index of a data table from a backend
bean?

Thanks in advance,

Regards,

Catalin 


		
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


Re: Tag dataTable and dataScroller usage

Posted by Catalin Kormos <ca...@yahoo.com>.
Hi Thomas,

I think the problem we were talking about, is kind of
outdated...i did't understood the usage of those
"*Var" attributes, like "pageIndexVar" for
dataScroller tag. Now it's clear. That attribute is
used as the "var" attribute for the dataTable tag, so
it's not meant to be used as i wanned. But maybe you
have a solution, for the more general need, to be able
to be informed about the page selection change by the
dataScroller or by the dataTable...i can't tell which
one should do the job. Any ideeas?

Regards,

Catalin

--- Thomas Spiegl <to...@apache.org> wrote:

> hi catalin,
> 
> can you send me your backend bean too?
> 
> 
> Catalin Kormos schrieb:
> 
> >Hi Thomas,
> >
> >Thanks for you interest.
> >
> >Here is the jsf code for the table:
> ><x:dataTable id="plannedProbes"
> >value="#{plannedProbes.tableModel.tableData}"
> >            
>
>rows="#{plannedProbes.tableModel.preferences.rowsPerPage}"
> >
> >            
>
>first="#{plannedProbes.tableModel.preferences.pageStartIndex}"
> >
> >             var="plannedProbe" 
> >             rowIndexVar="plannedProbesRowIndex" 
> >             rowCountVar="plannedProbesRowCount" 
> >             renderedIfEmpty="false" 
> >             preserveDataModel="false"
> >             preserveSort="true"
> >            
>
>sortColumn="#{plannedProbes.tableModel.comparator.columnName}"
> >            
>
>sortAscending="#{plannedProbes.tableModel.comparator.ascent}"
> >             rowClasses="whiteRow,grayRow"
> >             width="100%">
> >
> >    <h:column id="probeNo">
> >	...
> >    </h:column>
> ></x:dataTable>
> >
> >The code for the data scroller:
> ><x:dataScroller for="plannedProbes"
> >               
>
>fastStep="#{plannedProbes.tableModel.preferences.rowsPerPage}"
> >                pageCountVar="pageCount"
> >                pageIndexVar="pageIndex"
> >                paginator="true"
> >               
>
>paginatorMaxPages="#{plannedProbes.tableModel.preferences.paginatorMaxPages}"
> >
> >                styleClass="alignCenter"
> >                style="text:align:center;"
> >                paginatorColumnStyle="font-family: 
> >
>
>Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:normal;color:#000000;text-align:center;"
> >                       
> >paginatorActiveColumnStyle="font-family: 
> >
>
>Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:bold;color:#000000;text-align:center;"
> >                       
> >paginatorTableStyle="width:100%;text-align:center;"
> >                       
> >paginatorTableClass="alignCenter100Procent">
> >            <f:facet name="first" >
> >                <h:graphicImage
> >url="../images/datascroller/arrow-first.jpg"
> >border="0" />
> >            </f:facet>
> >            <f:facet name="last">
> >                <h:graphicImage
> >url="../images/datascroller/arrow-last.jpg"
> border="0"
> >/>
> >            </f:facet>
> >            <f:facet name="previous">
> >                <h:graphicImage
> >url="../images/datascroller/arrow-previous.jpg"
> >border="0" />
> >            </f:facet>
> >            <f:facet name="next">
> >                <h:graphicImage
> >url="../images/datascroller/arrow-next.jpg"
> border="0"
> >/>
> >            </f:facet>
> >            <f:facet name="fastforward">
> >                <h:graphicImage
> >url="../images/datascroller/arrow-ff.jpg"
> border="0"
> >/>
> >            </f:facet>
> >            <f:facet name="fastrewind">
> >                <h:graphicImage
> >url="../images/datascroller/arrow-fr.jpg"
> border="0"
> >/>
> >            </f:facet>
> ></x:dataScroller>
> >
> >Every value binding is made to a backend bean that
> has
> >setter and getter for it. Here is the code that 
> >
> >i use to get an attribute value from the request or
> a
> >parameter value from the request; both methods 
> >
> >return null for getting the value for "pageCount"
> or
> >"pageIndex":
> >
> >public static Object getAttributeFromRequest(Object
> >key)
> >{
> >    Object object = null;
> >    Map requestMap =
>
>FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
> >    object = requestMap.get(key);
> >    return object;
> >}
> >
> >public static String getParameterFromRequest(String
> >parameterName)
> >{
> >    String parameterValue = null;
> >    Map requestParameterMap = 
> >
>
>FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
> >    Iterator iterator =
> >requestParameterMap.keySet().iterator();
> >
> >    while(iterator.hasNext())
> >    {
> >        String key = (String)iterator.next();
> >        if(key.indexOf(parameterName) != -1 )
> >        {
> >            parameterValue =
> >(String)requestParameterMap.get(key);
> >            break;
> >        }
> >    }
> >    return parameterValue;
> >}
> >The code invoking those methods, in my backend bean
> >contructor (every call displayes "[null]"):
>
>logger.debug("rowIndexVar=["+BackendBeanCommons.getParameterFromRequest("pageIndex")+"]");
> >       
> >
>
>logger.debug("rowCount=["+BackendBeanCommons.getParameterFromRequest("rowCount")+"]");
> >      
> >        
>
>logger.debug("rowIndexVarAttr=["+BackendBeanCommons.getAttributeFromRequest("pageIndex")+"]");
>
>logger.debug("rowCountAttr=["+BackendBeanCommons.getAttributeFromRequest("pageCount")+"]");
> >
> >Any ideeas?
> >
> >Regards,
> >
> >Catalin
> >
> >--- Thomas Spiegl <to...@apache.org> wrote:
> >
> >  
> >
> >>hi Catalin,
> >>
> >>can you send me a jsp-example?
> >>
> >>thomas
> >>
> >>Catalin Kormos schrieb:
> >>
> >>    
> >>
> >>>Hi,
> >>>
> >>>I'm using myfaces-1.0.7, and i'm trying to
> >>>      
> >>>
> >>implement a
> >>    
> >>
> >>>table model backend bean to be able to control
> the
> >>>displayed page for table. The first time the
> table
> >>>      
> >>>
> >>is
> >>    
> >>
> >>>rendered i can set the "first" attribute to a
> >>>      
> >>>
> >>specific
> >>    
> >>
> >>>row index so it displayes the page content i
> want;
> >>>      
> >>>
> >>but
> >>    
> >>
> >>>then when i change de current page using the data
> >>>scroller, this does't change the "first"
> attribute
> >>>value of the table; so it can't find out which
> page
> >>>was selected by the user...there are some
> >>>      
> >>>
> >>attributes
> >>    
> >>
> >>>for dataScroller tag which seem to be very
> useful,
> >>>like the "pageIndexVar" attribute, but i have
> >>>      
> >>>
> >>tryied
> >>    
> >>
> >>>using it, and i always get a null value for it.
> Is
> >>>there someone  else who tryied using the value of
> >>>those attributes? Are these attributes used to
> >>>      
> >>>
> >>specify
> >>    
> >>
> >>>between requests which page was selected by the
> >>>      
> >>>
> >>user?
> >>    
> >>
> >>>how can these "var" attributes used? 
> >>>
> >>>More exactly, is there a preferred way to control
> >>>      
> >>>
> >>the
> >>    
> >>
> >>>selected page index of a data table from a
> backend
> >>>bean?
> >>>
> >>>Thanks in advance,
> >>>
> >>>Regards,
> >>>
> >>>Catalin 
> >>>
> >>>
> >>>		
> >>>__________________________________ 
> >>>Do you Yahoo!? 
> >>>Check out the new Yahoo! Front Page. 
> >>>www.yahoo.com 
> >>>
> >>>
> >>>
> >>>
> >>> 
> >>>
> >>>      
> >>>
> >>    
> >>
> >
> >
> >
> >		
> >__________________________________ 
> >Do you Yahoo!? 
> >Meet the all-new My Yahoo! - Try it today! 
> >http://my.yahoo.com 
> > 
> >
> >
> >
> >  
> >
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


Re: Tag dataTable and dataScroller usage

Posted by Thomas Spiegl <to...@apache.org>.
hi catalin,

can you send me your backend bean too?


Catalin Kormos schrieb:

>Hi Thomas,
>
>Thanks for you interest.
>
>Here is the jsf code for the table:
><x:dataTable id="plannedProbes"
>value="#{plannedProbes.tableModel.tableData}"
>            
>rows="#{plannedProbes.tableModel.preferences.rowsPerPage}"
>
>            
>first="#{plannedProbes.tableModel.preferences.pageStartIndex}"
>
>             var="plannedProbe" 
>             rowIndexVar="plannedProbesRowIndex" 
>             rowCountVar="plannedProbesRowCount" 
>             renderedIfEmpty="false" 
>             preserveDataModel="false"
>             preserveSort="true"
>            
>sortColumn="#{plannedProbes.tableModel.comparator.columnName}"
>            
>sortAscending="#{plannedProbes.tableModel.comparator.ascent}"
>             rowClasses="whiteRow,grayRow"
>             width="100%">
>
>    <h:column id="probeNo">
>	...
>    </h:column>
></x:dataTable>
>
>The code for the data scroller:
><x:dataScroller for="plannedProbes"
>               
>fastStep="#{plannedProbes.tableModel.preferences.rowsPerPage}"
>                pageCountVar="pageCount"
>                pageIndexVar="pageIndex"
>                paginator="true"
>               
>paginatorMaxPages="#{plannedProbes.tableModel.preferences.paginatorMaxPages}"
>
>                styleClass="alignCenter"
>                style="text:align:center;"
>                paginatorColumnStyle="font-family: 
>
>Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:normal;color:#000000;text-align:center;"
>                       
>paginatorActiveColumnStyle="font-family: 
>
>Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:bold;color:#000000;text-align:center;"
>                       
>paginatorTableStyle="width:100%;text-align:center;"
>                       
>paginatorTableClass="alignCenter100Procent">
>            <f:facet name="first" >
>                <h:graphicImage
>url="../images/datascroller/arrow-first.jpg"
>border="0" />
>            </f:facet>
>            <f:facet name="last">
>                <h:graphicImage
>url="../images/datascroller/arrow-last.jpg" border="0"
>/>
>            </f:facet>
>            <f:facet name="previous">
>                <h:graphicImage
>url="../images/datascroller/arrow-previous.jpg"
>border="0" />
>            </f:facet>
>            <f:facet name="next">
>                <h:graphicImage
>url="../images/datascroller/arrow-next.jpg" border="0"
>/>
>            </f:facet>
>            <f:facet name="fastforward">
>                <h:graphicImage
>url="../images/datascroller/arrow-ff.jpg" border="0"
>/>
>            </f:facet>
>            <f:facet name="fastrewind">
>                <h:graphicImage
>url="../images/datascroller/arrow-fr.jpg" border="0"
>/>
>            </f:facet>
></x:dataScroller>
>
>Every value binding is made to a backend bean that has
>setter and getter for it. Here is the code that 
>
>i use to get an attribute value from the request or a
>parameter value from the request; both methods 
>
>return null for getting the value for "pageCount" or
>"pageIndex":
>
>public static Object getAttributeFromRequest(Object
>key)
>{
>    Object object = null;
>    Map requestMap =
>FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
>    object = requestMap.get(key);
>    return object;
>}
>
>public static String getParameterFromRequest(String
>parameterName)
>{
>    String parameterValue = null;
>    Map requestParameterMap = 
>
>FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
>    Iterator iterator =
>requestParameterMap.keySet().iterator();
>
>    while(iterator.hasNext())
>    {
>        String key = (String)iterator.next();
>        if(key.indexOf(parameterName) != -1 )
>        {
>            parameterValue =
>(String)requestParameterMap.get(key);
>            break;
>        }
>    }
>    return parameterValue;
>}
>The code invoking those methods, in my backend bean
>contructor (every call displayes "[null]"):
>logger.debug("rowIndexVar=["+BackendBeanCommons.getParameterFromRequest("pageIndex")+"]");
>       
>
>logger.debug("rowCount=["+BackendBeanCommons.getParameterFromRequest("rowCount")+"]");
>      
>        
>logger.debug("rowIndexVarAttr=["+BackendBeanCommons.getAttributeFromRequest("pageIndex")+"]");
>logger.debug("rowCountAttr=["+BackendBeanCommons.getAttributeFromRequest("pageCount")+"]");
>
>Any ideeas?
>
>Regards,
>
>Catalin
>
>--- Thomas Spiegl <to...@apache.org> wrote:
>
>  
>
>>hi Catalin,
>>
>>can you send me a jsp-example?
>>
>>thomas
>>
>>Catalin Kormos schrieb:
>>
>>    
>>
>>>Hi,
>>>
>>>I'm using myfaces-1.0.7, and i'm trying to
>>>      
>>>
>>implement a
>>    
>>
>>>table model backend bean to be able to control the
>>>displayed page for table. The first time the table
>>>      
>>>
>>is
>>    
>>
>>>rendered i can set the "first" attribute to a
>>>      
>>>
>>specific
>>    
>>
>>>row index so it displayes the page content i want;
>>>      
>>>
>>but
>>    
>>
>>>then when i change de current page using the data
>>>scroller, this does't change the "first" attribute
>>>value of the table; so it can't find out which page
>>>was selected by the user...there are some
>>>      
>>>
>>attributes
>>    
>>
>>>for dataScroller tag which seem to be very useful,
>>>like the "pageIndexVar" attribute, but i have
>>>      
>>>
>>tryied
>>    
>>
>>>using it, and i always get a null value for it. Is
>>>there someone  else who tryied using the value of
>>>those attributes? Are these attributes used to
>>>      
>>>
>>specify
>>    
>>
>>>between requests which page was selected by the
>>>      
>>>
>>user?
>>    
>>
>>>how can these "var" attributes used? 
>>>
>>>More exactly, is there a preferred way to control
>>>      
>>>
>>the
>>    
>>
>>>selected page index of a data table from a backend
>>>bean?
>>>
>>>Thanks in advance,
>>>
>>>Regards,
>>>
>>>Catalin 
>>>
>>>
>>>		
>>>__________________________________ 
>>>Do you Yahoo!? 
>>>Check out the new Yahoo! Front Page. 
>>>www.yahoo.com 
>>>
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>>    
>>
>
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Meet the all-new My Yahoo! - Try it today! 
>http://my.yahoo.com 
> 
>
>
>
>  
>


Re: Tag dataTable and dataScroller usage

Posted by Catalin Kormos <ca...@yahoo.com>.
Hi Thomas,

Thanks for you interest.

Here is the jsf code for the table:
<x:dataTable id="plannedProbes"
value="#{plannedProbes.tableModel.tableData}"
            
rows="#{plannedProbes.tableModel.preferences.rowsPerPage}"

            
first="#{plannedProbes.tableModel.preferences.pageStartIndex}"

             var="plannedProbe" 
             rowIndexVar="plannedProbesRowIndex" 
             rowCountVar="plannedProbesRowCount" 
             renderedIfEmpty="false" 
             preserveDataModel="false"
             preserveSort="true"
            
sortColumn="#{plannedProbes.tableModel.comparator.columnName}"
            
sortAscending="#{plannedProbes.tableModel.comparator.ascent}"
             rowClasses="whiteRow,grayRow"
             width="100%">

    <h:column id="probeNo">
	...
    </h:column>
</x:dataTable>

The code for the data scroller:
<x:dataScroller for="plannedProbes"
               
fastStep="#{plannedProbes.tableModel.preferences.rowsPerPage}"
                pageCountVar="pageCount"
                pageIndexVar="pageIndex"
                paginator="true"
               
paginatorMaxPages="#{plannedProbes.tableModel.preferences.paginatorMaxPages}"

                styleClass="alignCenter"
                style="text:align:center;"
                paginatorColumnStyle="font-family: 

Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:normal;color:#000000;text-align:center;"
                       
paginatorActiveColumnStyle="font-family: 

Arial,Helvetica,Sans-Serif;font-size:11px;font-weight:bold;color:#000000;text-align:center;"
                       
paginatorTableStyle="width:100%;text-align:center;"
                       
paginatorTableClass="alignCenter100Procent">
            <f:facet name="first" >
                <h:graphicImage
url="../images/datascroller/arrow-first.jpg"
border="0" />
            </f:facet>
            <f:facet name="last">
                <h:graphicImage
url="../images/datascroller/arrow-last.jpg" border="0"
/>
            </f:facet>
            <f:facet name="previous">
                <h:graphicImage
url="../images/datascroller/arrow-previous.jpg"
border="0" />
            </f:facet>
            <f:facet name="next">
                <h:graphicImage
url="../images/datascroller/arrow-next.jpg" border="0"
/>
            </f:facet>
            <f:facet name="fastforward">
                <h:graphicImage
url="../images/datascroller/arrow-ff.jpg" border="0"
/>
            </f:facet>
            <f:facet name="fastrewind">
                <h:graphicImage
url="../images/datascroller/arrow-fr.jpg" border="0"
/>
            </f:facet>
</x:dataScroller>

Every value binding is made to a backend bean that has
setter and getter for it. Here is the code that 

i use to get an attribute value from the request or a
parameter value from the request; both methods 

return null for getting the value for "pageCount" or
"pageIndex":

public static Object getAttributeFromRequest(Object
key)
{
    Object object = null;
    Map requestMap =
FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    object = requestMap.get(key);
    return object;
}

public static String getParameterFromRequest(String
parameterName)
{
    String parameterValue = null;
    Map requestParameterMap = 

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    Iterator iterator =
requestParameterMap.keySet().iterator();

    while(iterator.hasNext())
    {
        String key = (String)iterator.next();
        if(key.indexOf(parameterName) != -1 )
        {
            parameterValue =
(String)requestParameterMap.get(key);
            break;
        }
    }
    return parameterValue;
}
The code invoking those methods, in my backend bean
contructor (every call displayes "[null]"):
logger.debug("rowIndexVar=["+BackendBeanCommons.getParameterFromRequest("pageIndex")+"]");
       

logger.debug("rowCount=["+BackendBeanCommons.getParameterFromRequest("rowCount")+"]");
      
        
logger.debug("rowIndexVarAttr=["+BackendBeanCommons.getAttributeFromRequest("pageIndex")+"]");
logger.debug("rowCountAttr=["+BackendBeanCommons.getAttributeFromRequest("pageCount")+"]");

Any ideeas?

Regards,

Catalin

--- Thomas Spiegl <to...@apache.org> wrote:

> hi Catalin,
> 
> can you send me a jsp-example?
> 
> thomas
> 
> Catalin Kormos schrieb:
> 
> >Hi,
> >
> >I'm using myfaces-1.0.7, and i'm trying to
> implement a
> >table model backend bean to be able to control the
> >displayed page for table. The first time the table
> is
> >rendered i can set the "first" attribute to a
> specific
> >row index so it displayes the page content i want;
> but
> >then when i change de current page using the data
> >scroller, this does't change the "first" attribute
> >value of the table; so it can't find out which page
> >was selected by the user...there are some
> attributes
> >for dataScroller tag which seem to be very useful,
> >like the "pageIndexVar" attribute, but i have
> tryied
> >using it, and i always get a null value for it. Is
> >there someone  else who tryied using the value of
> >those attributes? Are these attributes used to
> specify
> >between requests which page was selected by the
> user?
> >how can these "var" attributes used? 
> >
> >More exactly, is there a preferred way to control
> the
> >selected page index of a data table from a backend
> >bean?
> >
> >Thanks in advance,
> >
> >Regards,
> >
> >Catalin 
> >
> >
> >		
> >__________________________________ 
> >Do you Yahoo!? 
> >Check out the new Yahoo! Front Page. 
> >www.yahoo.com 
> > 
> >
> >
> >
> >  
> >
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


Re: Tag dataTable and dataScroller usage

Posted by Thomas Spiegl <to...@apache.org>.
hi Catalin,

can you send me a jsp-example?

thomas

Catalin Kormos schrieb:

>Hi,
>
>I'm using myfaces-1.0.7, and i'm trying to implement a
>table model backend bean to be able to control the
>displayed page for table. The first time the table is
>rendered i can set the "first" attribute to a specific
>row index so it displayes the page content i want; but
>then when i change de current page using the data
>scroller, this does't change the "first" attribute
>value of the table; so it can't find out which page
>was selected by the user...there are some attributes
>for dataScroller tag which seem to be very useful,
>like the "pageIndexVar" attribute, but i have tryied
>using it, and i always get a null value for it. Is
>there someone  else who tryied using the value of
>those attributes? Are these attributes used to specify
>between requests which page was selected by the user?
>how can these "var" attributes used? 
>
>More exactly, is there a preferred way to control the
>selected page index of a data table from a backend
>bean?
>
>Thanks in advance,
>
>Regards,
>
>Catalin 
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Check out the new Yahoo! Front Page. 
>www.yahoo.com 
> 
>
>
>
>  
>