You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Feris Thia <fe...@gmail.com> on 2006/09/07 19:28:06 UTC

DataTable and DataScroller problem

 Hi,

I'm quite new to JSF and MyFaces. I have page that will do searching based
on a keyword and populate table with paging capability. I'm using lates
stable MyFaces and Tomahowk extension.

The problem is I can only seen 1 page. And when I try to move to another
page. I have no data display on my dataTable.

Can someone give me some clue on my problem ??

My JSP page is shown below
-------------------------------------------------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<HTML>
<HEAD>
<TITLE><h:outputText value="#{prop.appTitle}"/></TITLE>
<link rel="stylesheet" type="text/css" href="./css/basic.css" />
</HEAD>
<BODY>
<body>
<f:view>
<h:form>

    <f:loadBundle
basename="org.apache.myfaces.examples.resource.example_messages"
var="example_messages"/>

	<h:commandButton id="validateButton" type="submit" value="search"
actionListener="#{mydocs.doSearch}"/>

	<h:panelGroup id="body">
        <t:dataTable id="data"
                styleClass="scrollerTable"
                headerClass="standardTable_Header"
                footerClass="standardTable_Header"
                rowClasses="standardTable_Row1,standardTable_Row2"

columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
                var="car"
                value="#{mydocs.data}"
                preserveDataModel="true"
                rows="10"
           >
           <h:column>
               <f:facet name="header">
               </f:facet>
               <h:outputText value="#{car.documentID}" />
           </h:column>

           <h:column>
               <f:facet name="header">
                  <h:outputText value="#{example_messages['label_cars']}" />
               </f:facet>
               <h:outputText value="#{car.documentName}" />
           </h:column>

           <h:column>
               <f:facet name="header">
                  <h:outputText value="#{example_messages['label_color']}" />
               </f:facet>
               <h:outputText value="#{car.documentName}" />
           </h:column>

        </t:dataTable>

        <h:panelGrid columns="1" styleClass="scrollerTable2"
columnClasses="standardTable_ColumnCentered" >
            <t:dataScroller id="scroll_1"
                    for="data"
                    fastStep="10"
                    pageCountVar="pageCount"
                    pageIndexVar="pageIndex"
                    styleClass="scroller"
                    paginator="true"
                    paginatorMaxPages="9"
                    paginatorTableClass="paginator"
                    paginatorActiveColumnStyle="font-weight:bold;"
                    immediate="true"
                    >
                <f:facet name="first" >
                    <t:graphicImage url="images/arrow-first.gif" border="1" />
                </f:facet>
                <f:facet name="last">
                    <t:graphicImage url="images/arrow-last.gif" border="1" />
                </f:facet>
                <f:facet name="previous">
                    <t:graphicImage url="images/arrow-previous.gif"
border="1" />
                </f:facet>
                <f:facet name="next">
                    <t:graphicImage url="images/arrow-next.gif" border="1" />
                </f:facet>
                <f:facet name="fastforward">
                    <t:graphicImage url="images/arrow-ff.gif" border="1" />
                </f:facet>
                <f:facet name="fastrewind">
                    <t:graphicImage url="images/arrow-fr.gif" border="1" />
                </f:facet>
            </t:dataScroller>
            <t:dataScroller id="scroll_2"
                    for="data"
                    rowsCountVar="rowsCount"
                    displayedRowsCountVar="displayedRowsCountVar"
                    firstRowIndexVar="firstRowIndex"
                    lastRowIndexVar="lastRowIndex"
                    pageCountVar="pageCount"
                    immediate="true"
                    pageIndexVar="pageIndex"
                    >
                <h:outputFormat
value="#{example_messages['dataScroller_pages']}"
styleClass="standard" >
                    <f:param value="#{rowsCount}" />
                    <f:param value="#{displayedRowsCountVar}" />
                    <f:param value="#{firstRowIndex}" />
                    <f:param value="#{lastRowIndex}" />
                    <f:param value="#{pageIndex}" />
                    <f:param value="#{pageCount}" />
                </h:outputFormat>
            </t:dataScroller>
        </h:panelGrid>

    </h:panelGroup>
    <t:commandLink value="test" immediate="true" />

</h:form>
</f:view>

</body>
</BODY>
</HTML>


-------------------------------------------------------------------------------------------------------------------

and my bean as follows..

-------------------------------------------------------------------------------------------------------------------


*package* org.phi.dms;

*import* java.io.Serializable;
*import* java.util.LinkedList;
*import* java.util.List;

*import* javax.faces.event.ActionEvent;

*public* *class* DocumentsList *implements* Serializable {
	/**
	 *
	 */
	*private* *static* *final* *long* serialVersionUID = 1;
	
	*private* List objDocs = *new* LinkedList();
	
	*public* *void* addDocument(Document e)
	{
		objDocs.add(e);
	}
	
	*public* List getData()
	{	
		*return* objDocs;
	}
	
	*public* *void* doSearch(ActionEvent event)
	{
		objDocs.clear();
		
		addDocument(*new* Document("a","b"));
		addDocument(*new* Document("a","c"));
		addDocument(*new* Document("a","d"));
		addDocument(*new* Document("a","e"));
		addDocument(*new* Document("a","f"));
		addDocument(*new* Document("a","g"));
		addDocument(*new* Document("b","g"));
		addDocument(*new* Document("c","g"));
		addDocument(*new* Document("d","g"));
		addDocument(*new* Document("e","g"));
		addDocument(*new* Document("f","g"));
		addDocument(*new* Document("g","g"));
		addDocument(*new* Document("h","g"));
	}
}


-------------------------------------------------------------------------------------------------------------------

and

-------------------------------------------------------------------------------------------------------------------


*package* org.phi.dms;

*import* java.io.Serializable;

*public* *class* Document *implements* Serializable {
	/**
	 *
	 */
	*private* *static* *final* *long* serialVersionUID = 1;
	
	*private* String documentID;
	*private* String documentName;
	
	*public* Document(String myid, String myname)
	{
		documentID = myid;
		documentName = myname;
	}
	
	*public* String getDocumentID() {
		*return* documentID;
	}
	*public* *void* setDocumentID(String documentID) {
		this.documentID = documentID;
	}
	*public* String getDocumentName() {
		*return* documentName;
	}
	*public* *void* setDocumentName(String documentName) {
		this.documentName = documentName;
	}	
}

-------------------------------------------------------------------------------------------------------------------


Regards,

Feris

Re: DataTable and DataScroller problem

Posted by Feris Thia <fe...@gmail.com>.
Dear Mr. Arvind,

On 9/8/06, Mr Arvind Pandey <ar...@yahoo.co.in> wrote:Hi,

   You have used <t:dataScroller> twice in the page .
Remove the second one. Rest is I think ok. If still
some problem is there pls let me know I have worked a
lot on this. May be I will be able to help you.
I think that solved my problem already. Thanks for the help.

Regards,

Feris

DataTable problem

Posted by Mr Arvind Pandey <ar...@yahoo.co.in>.
Hi all,

     I have a data table as shown below. As you can
see forceIdIndexFormula and rowId is same. Problem is
when I click on a row which has already been deleted
by someone else (during concurrent operations)  , the
row simply disappears. It does not invoke the set
method that i have written in my bean. And in set
method itself I come to know the row id of the row
which has been clicked. But this method does not get
invoked if row has been deleted by someone else(by
other user). 
     In set method itself I can give message to user
whether row has been deleted by someone else. One soln
to this is that I can make preserveDataModel="true".
But if preserveDataModel is true then on deletion of
row , it deletes the entries form database but row
still remains with table.
    what I need is that on deletion of row the row
should disapper from table and if I try to delete the
same row which has been deleted by other user then I
should be able to get the message like row has already
been deleted by other user.

      Table is shown below: 

<t:dataTable    id="data"                
                ........
                ........
       	        var="cust"				
                preserveDataModel="false"
                forceIdIndexFormula="#{cust.Id}"	     
          binding="#{customers.data}"
                ......
                .......
        	rowId="#{cust.Id}"
                ...........
                ...........
     >

<h:coloumn...............>
.............
...........
...........
</h:coloumn>

<h:coloumn...............>
.............
...........
...........
</h:coloumn>

<h:coloumn...............>
.............
...........This is delete button for the rows. If I
click the delete button, row should disapper from the
table in same page. But if the row is already deleted
by some other user then I shold be able to get a
nessage like 'row has already been deleted ' .
...........
</h:coloumn>
</t:datatable>


   Any suggestion ?
Thanks and regards....
Arvind





		
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/

Re: DataTable and DataScroller problem

Posted by Mr Arvind Pandey <ar...@yahoo.co.in>.
Hi,
   
   You have used <t:dataScroller> twice in the page .
Remove the second one. Rest is I think ok. If still
some problem is there pls let me know I have worked a
lot on this. May be I will be able to help you.

Regards....
Arvind


--- Feris Thia <fe...@gmail.com> wrote:

>  Hi,
> 
> I'm quite new to JSF and MyFaces. I have page that
> will do searching based
> on a keyword and populate table with paging
> capability. I'm using lates
> stable MyFaces and Tomahowk extension.
> 
> The problem is I can only seen 1 page. And when I
> try to move to another
> page. I have no data display on my dataTable.
> 
> Can someone give me some clue on my problem ??
> 
> My JSP page is shown below
>
-------------------------------------------------------------------------------------------------------------------
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
> Transitional//EN">
> <%@ taglib uri="http://java.sun.com/jsf/core"
> prefix="f" %>
> <%@ taglib uri="http://java.sun.com/jsf/html"
> prefix="h" %>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk"
> prefix="t"%>
> <HTML>
> <HEAD>
> <TITLE><h:outputText
> value="#{prop.appTitle}"/></TITLE>
> <link rel="stylesheet" type="text/css"
> href="./css/basic.css" />
> </HEAD>
> <BODY>
> <body>
> <f:view>
> <h:form>
> 
>     <f:loadBundle
>
basename="org.apache.myfaces.examples.resource.example_messages"
> var="example_messages"/>
> 
> 	<h:commandButton id="validateButton" type="submit"
> value="search"
> actionListener="#{mydocs.doSearch}"/>
> 
> 	<h:panelGroup id="body">
>         <t:dataTable id="data"
>                 styleClass="scrollerTable"
>                 headerClass="standardTable_Header"
>                 footerClass="standardTable_Header"
>                
> rowClasses="standardTable_Row1,standardTable_Row2"
> 
>
columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
>                 var="car"
>                 value="#{mydocs.data}"
>                 preserveDataModel="true"
>                 rows="10"
>            >
>            <h:column>
>                <f:facet name="header">
>                </f:facet>
>                <h:outputText
> value="#{car.documentID}" />
>            </h:column>
> 
>            <h:column>
>                <f:facet name="header">
>                   <h:outputText
> value="#{example_messages['label_cars']}" />
>                </f:facet>
>                <h:outputText
> value="#{car.documentName}" />
>            </h:column>
> 
>            <h:column>
>                <f:facet name="header">
>                   <h:outputText
> value="#{example_messages['label_color']}" />
>                </f:facet>
>                <h:outputText
> value="#{car.documentName}" />
>            </h:column>
> 
>         </t:dataTable>
> 
>         <h:panelGrid columns="1"
> styleClass="scrollerTable2"
> columnClasses="standardTable_ColumnCentered" >
>             <t:dataScroller id="scroll_1"
>                     for="data"
>                     fastStep="10"
>                     pageCountVar="pageCount"
>                     pageIndexVar="pageIndex"
>                     styleClass="scroller"
>                     paginator="true"
>                     paginatorMaxPages="9"
>                     paginatorTableClass="paginator"
>                    
> paginatorActiveColumnStyle="font-weight:bold;"
>                     immediate="true"
>                     >
>                 <f:facet name="first" >
>                     <t:graphicImage
> url="images/arrow-first.gif" border="1" />
>                 </f:facet>
>                 <f:facet name="last">
>                     <t:graphicImage
> url="images/arrow-last.gif" border="1" />
>                 </f:facet>
>                 <f:facet name="previous">
>                     <t:graphicImage
> url="images/arrow-previous.gif"
> border="1" />
>                 </f:facet>
>                 <f:facet name="next">
>                     <t:graphicImage
> url="images/arrow-next.gif" border="1" />
>                 </f:facet>
>                 <f:facet name="fastforward">
>                     <t:graphicImage
> url="images/arrow-ff.gif" border="1" />
>                 </f:facet>
>                 <f:facet name="fastrewind">
>                     <t:graphicImage
> url="images/arrow-fr.gif" border="1" />
>                 </f:facet>
>             </t:dataScroller>
>             <t:dataScroller id="scroll_2"
>                     for="data"
>                     rowsCountVar="rowsCount"
>                    
> displayedRowsCountVar="displayedRowsCountVar"
>                     firstRowIndexVar="firstRowIndex"
>                     lastRowIndexVar="lastRowIndex"
>                     pageCountVar="pageCount"
>                     immediate="true"
>                     pageIndexVar="pageIndex"
>                     >
>                 <h:outputFormat
> value="#{example_messages['dataScroller_pages']}"
> styleClass="standard" >
>                     <f:param value="#{rowsCount}" />
>                     <f:param
> value="#{displayedRowsCountVar}" />
>                     <f:param
> value="#{firstRowIndex}" />
>                     <f:param value="#{lastRowIndex}"
> />
>                     <f:param value="#{pageIndex}" />
>                     <f:param value="#{pageCount}" />
>                 </h:outputFormat>
>             </t:dataScroller>
>         </h:panelGrid>
> 
>     </h:panelGroup>
>     <t:commandLink value="test" immediate="true" />
> 
> </h:form>
> </f:view>
> 
> </body>
> </BODY>
> </HTML>
> 
> 
>
-------------------------------------------------------------------------------------------------------------------
> 
> and my bean as follows..
> 
>
-------------------------------------------------------------------------------------------------------------------
> 
> 
> *package* org.phi.dms;
> 
> *import* java.io.Serializable;
> *import* java.util.LinkedList;
> *import* java.util.List;
> 
> *import* javax.faces.event.ActionEvent;
> 
> *public* *class* DocumentsList *implements*
> Serializable {
> 	/**
> 	 *
> 	 */
> 	*private* *static* *final* *long* serialVersionUID
> = 1;
> 	
> 	*private* List objDocs = *new* LinkedList();
> 	
> 	*public* *void* addDocument(Document e)
> 	{
> 		objDocs.add(e);
> 	}
> 	
> 	*public* List getData()
> 	{	
> 		*return* objDocs;
> 	}
> 	
> 
=== message truncated ===



		
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/