Hi,

I am tring to use a variable for *pageSize* to work in
the *paging* attribute of the datagrid but can't get
it to work. I am attaching my code for your perusal.
Could you please see where I am doing wrong in the
code?

I declared a scope variable 

-- int pageSize = 2; 

which I used in 

<paging size="${pageSize}"
nextUrlVar="next" previousUrlVar="previous"
pagesVar="pages"/>

It is working if I do this way: <paging size="2"
nextUrlVar="next" previousUrlVar="previous"
pagesVar="pages"/>

My actualy intention is to let the user choose the
pageSize in the form he submits to get to this results
page.

I would appreciate any help on this.

Thanks,
-Siva



                
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-portal-html" prefix="portalhtml" %>
<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %>
<%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c"%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/datagrid-1.0"; prefix="ui" %>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1" import=" 
com.flowserve.portlet.imagerepos.struts.beans.Image,com.flowserve.portlet.imagerepos.struts.action.ImageRender,
javax.servlet.jsp.PageContext,org.apache.taglibs.datagrid.Page"
%>

<html:html locale="true">
<style>

     th a:link      { text-decoration: none; color: black }

     th a:visited   { text-decoration: none; color: black }

     .rows          { background-color: white }
     .item          { border-bottom: 1px solid #gray }

     .hiliterows    { background-color: #716F64; color: white; font-weight: 
bold }

     .alternaterows { background-color: #F0EFE8 }

     .header        { background-color: #ECE9D0; border-right: 1px solid 
#C7C5B2; border-left: 1px solid white; border-bottom: 3px solid #D6D2C2; 
border-top: 1px solid white; font-weight: bold }

     .footer        { background-color: #ECE9D8; border-right: 1px solid 
#C7C5B2; border-left: 1px solid white; border-bottom: 2px solid #E2DECD; 
border-top: 1px solid white }

     .datagrid      { border: 1px solid #C7C5B2; font-family: arial; font-size: 
9pt; font-weight: normal }

   </style>
   
<jsp:useBean id="imageList" class="java.util.List" scope="session" />

<p class="wpsInlineHelpText"><html:img page="/images/msg_inline_help.gif" 
border="0" />
<bean:message key="searchimageresults.title" /> </p>



<SCRIPT LANGUAGE="JavaScript">
        function submitForm(form, mode)
        {
                form.actionFlag.value=mode;     
                        
                if(mode == 'delete' && !confirm('Delete the selected records?'))
                        return;
                        
                if (mode =='edit' && !validateSelected(form.selectedImage))
                        return;
                        
                form.submit(); //finally submit
        }
        
        //  ---------------------------------------------------------- //
        //  Validate a selection was made
        //  ---------------------------------------------------------- //
        function validateSelected(radio) {
                        if (radio.checked)
                                return true;
                        for ( var i=0; i<radio.length; i++ ) {
                                if ( radio[i].checked )
                                return true;
                         }
                 alert("Make a selection and try again");
                         return false;
        }
</SCRIPT>

<html:form method="post" action="/modify">
        <html:hidden property="actionFlag" />   
        
        <div id="result">
        
        <%int pageSize=1; //scoped variable for pageSize
        
        if (imageList.size() > 0) { 
        %>      
        
        <%=pageSize %>  
        
        <ui:dataGrid items="${imageList}" var="image" name="datagrid1" 
cellPadding="0" cellSpacing="0" width="600" height="200" styleClass="datagrid">
        
        <columns>
                
                <column width="10">
              <header value="Edit " hAlign="left" styleClass="header"/>
                <item  hAlign="center" styleClass="item">
                <![CDATA[
                        <input type="radio" name="selectedImage" 
value="${image.id}"/>
                        
                ]]>
                </item>      
            </column>
                
            <column width="200" order="true">
              <header value="Image Title" hAlign="left" styleClass="header"/>
              <item   value="${image.imageTitle}" hAlign="left" 
styleClass="item"/> 
            </column>
            
            <column width="100">
              <header value="Thumbnail" hAlign="right" styleClass="header"/>
              <item   value="thumbnail" hAlign="right" styleClass="item">
                <![CDATA[
                        <A href="javascript: 
window.open('${image.contextPath}/ImageRender?id=${image.id}&img=${image.lowResImageFilePath}&type=gif','','toolbar=no,
 width=475, height=600, resizable=1, scrollbars=0'); void('');">
                                <img 
src="${image.contextPath}/ImageRender?id=${image.id}&img=${image.thumbnailFilePath}&type=gif"
 border="0" width="50" height="50"> 
                        </a>
                ]]>
              </item>
            </column>
            
            <column width="100">
              <header value="Download" hAlign="right" styleClass="header"/>
              <item   value="highresimage" hAlign="right" styleClass="item">
                <![CDATA[
                        
                        <A href="javascript: 
window.open('${image.contextPath}/ImageRender?id=${image.id}&img=${image.highResImagePath}&type=gif','','toolbar=no,
 width=475, height=600, resizable=1, scrollbars=0'); void('');">
                                <img 
src="${image.contextPath}/html/edit/images/download.jpg" border="0"> 
                        </a>
                        
                ]]>
              </item>
            </column>
            
            <column width="30">
              <header value="Delete" hAlign="center" styleClass="header"/>
                <item  hAlign="center" styleClass="item">
                <![CDATA[
                        <input name="deleteId" type="checkbox" 
value='${image.id}'>
                ]]>
                </item>      
            </column>
          
          </columns>
          
          <rows  styleClass="rows"/>      
          <alternateRows styleClass="alternaterows"/>             
          
          <paging size="${pageSize}" nextUrlVar="next" 
previousUrlVar="previous" pagesVar="pages"/>
        
        </ui:dataGrid>
        
        <%=pageSize%>   
        
        <table width="500" style="font-family: arial; font-size: 10pt">
                <tr>
                        <td align="left" width="33%">
                                <c:if test="${previous != null}">
                                <a href="<c:out 
value="${previous}"/>">Previous</a>
                                </c:if>
                                &nbsp;
                        </td>
                        <td align="center" width="33%">
                                <c:forEach items="${pages}" var="page">
                                <c:choose>
                                  <c:when test="${page.current}">
                                    <b><a href="<c:out 
value="${page.url}"/>"><font color="red"><c:out 
value="${page.index}"/></font></a></b> 
                                  </c:when>
                                  <c:otherwise>
                                    <a href="<c:out 
value="${page.url}"/>"><c:out value="${page.index}"/></a>
                                  </c:otherwise>
                                </c:choose>
                                </c:forEach>
                        </td>
                        <td align="right" width="33%">
                                &nbsp;
                                <c:if test="${next != null}">
                                <a href="<c:out value="${next}"/>">Next</a>
                                </c:if>
                        </td>
                </tr>
        </table>
        </div>
        <%}else{%>              
                <b><bean:message key="searchimageresults.norecords" /></b>
        <%}%>
        
        <p></p>
        <table cellspacing="4" cellpadding="0" border="0" width="95%"
                align="center">
                <tr>
                        <td>
                        <!--
                        <input class="wpsButtonText" type="submit"
                                value='<bean:message key="home"/>'
                                
onclick="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='home';">

                        <input class="wpsButtonText"
                                type="submit" value='<bean:message 
key="searchagain"/>'
                                
onclick="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='searchagain';">
                        -->
                        <b>
                        <a 
href="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='home';document.<portletAPI:encodeNamespace
 value='ImageForm'/>.submit();">                                                
       
                                <bean:message key="home"/></a> | 
                        <a 
href="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='searchagain';document.<portletAPI:encodeNamespace
 value='ImageForm'/>.submit();">
                                <bean:message key="searchagain"/></a>           
                        
                        <% if (imageList.size() > 0) { %>
                        <!--
                        <input class="wpsButtonText" type="submit" 
value='<bean:message key="edit"/>'
                                
onclick="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='edit';
                                return validateSelected(selectedImage)">
                        
                        <input class="wpsButtonText" type="submit"
                                value='<bean:message key="delete"/>'
                                
onclick="javascript:document.<portletAPI:encodeNamespace 
value='ImageForm'/>.actionFlag.value='delete';return confirm('Delete the 
selected records?');">
                        -->
                        | <a 
href="javascript:submitForm(document.<portletAPI:encodeNamespace 
value='ImageForm'/>, 'edit');">
                                <bean:message key="edit"/></a> |  
                        <a 
href="javascript:submitForm(document.<portletAPI:encodeNamespace 
value='ImageForm'/>, 'delete');">
                                <bean:message key="delete"/></a>
                        </b>    
                        <%}%>   
                        </td>
                </tr>
        </table>
</html:form></html:html>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to