Hi Andreas,
yes, I have looked at the demo pages and the source code for it. The problem
I am having is a little strange...
let me try to explain.
I have a page where I want to use a partial component rendering like in the
example http://opencomponentry.com:8080/tacos/ajax/EffectsExample.html where
I show or hide a search form. This I have implemented and it works. The next
step is that in the search form I want to add some validation in my listener
method so I check that at least one field in the search form is populated.
If the search form get past the validation then I want to display yet
another Partial Component to show or hide the search result in a grid
component.
This is where things start to behave strange... In IE7 the validation kicks
in at the first click if I have set an error. In Firefox it take multiple
clicks befor the validation shows. Also for now I have only put the Grid
component code from the demo in the content of the second Partial component.
In IE7 the Grid component comes up the first time I click on the search
button and in Firfox I need to click 4 times on the search button before the
Grid component is displayed. (with a valid search form).
Also in IE7 the mask I have for SSN does not  show the first time, but after
one click (either Validation kicks in or it displays the Grid) the mask
shows up and work. And the DatePicker does not work in IE7...

Do you have any ideer on how to fix these issues?

This is my code:
Page file:

<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry
Specification 4.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
        
<page-specification
class="com.mycompany.ui.web.action.securepages.rep.RepDocumentPage">
        
    <!-- COMPONENTS -->
        <component id="pageTitleWithMenu" type="PageTitleWithMenu" />
        
        <component id="repTopBar" type="RepTopBar" >
                <binding name="topBarName" value="currentTopBarName" />
        </component>

    <component id="reportTable" type="tacos:Grid">
        <binding name="widgetId" value="literal:testDiv"/>
        <binding name="columns" value="ognl:gridColumns"/>
        <binding name="source" value="ognl:gridData"/>
        <!-- <binding name="row" value="ognl:gridTableRow"/>-->

        <binding name="pageSize" value="ognl:20"/>
        <binding name="enableMultipleSelect" value="true"/>
        <binding name="initialSortOrder" value="ognl:initSortOrder"/>
        <binding name="initialSortColumn" value="ognl:initSortColumn"/>
        <binding name="showFilter" value="true"/>
        <binding name="footerRow" value="ognl:totalRow"/>
        <binding name="headerClass" value="literal:Header"/>
        <binding name="bodyClass" value="literal:scrollContent"/>
        <binding name="footerClass" value="literal:fixedFooter"/>
        <binding name="rowAlternateClass" value="literal:alternateRow"/>
        <binding name="containerClass" value="literal:tableContainer"/>
        <binding name="headerSortUpClass" value="literal:headerSortUp"/>
        <binding name="headerSortDownClass" value="literal:headerSortDown"/>
        <binding name="title" value="literal:Demo Report"/>
        <binding name="info" value="ognl:info"/>
    </component>  

    <component id="linkSearchForm" type="tacos:AjaxDirectLink">
        <binding name="listener" value="listener:onSearchForm"/>
        <binding name="updateComponents" value="ognl:{'searchBlock'}"/>
    </component>
    
    <component id="linkSearchResult" type="tacos:AjaxDirectLink">
        <binding name="listener" value="listener:onSearchResult"/>
        <binding name="updateComponents" value="ognl:{'showSearchResult'}"/>
    </component>
    
    <component id="insertTime" type="Insert">
                <binding name="format"
value="@[EMAIL PROTECTED]"/>
                <binding name="value" value="new java.util.Date()"/>
        </component>
        
</page-specification>


the html file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html jwcid="@Shell" title="Investalink 2.0 - Website Admin"
xmlns="http://www.w3.org/1999/xhtml";>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" 
/>
        <title>Investalink 2.0 - Website Admin.</title>
        <link href="/templates/defaultbluelight/css/reptopbar.css" 
rel="stylesheet"
type="text/css" media="screen" />
        <link href="/templates/defaultbluelight/css/displaybox.css"
rel="stylesheet" type="text/css" media="screen" />
        <link href="/templates/defaultbluelight/css/pagetitlewithmenu.css"
rel="stylesheet" type="text/css" media="screen" />
        <link href="/templates/defaultbluelight/css/formcontrols.css"
rel="stylesheet" type="text/css" media="screen" />
        <link href="/templates/defaultbluelight/css/repdocument.css"
rel="stylesheet" type="text/css" media="screen" />
        <link href="/css/jscalendar/skins/aqua/theme.css" rel="stylesheet"
type="text/css" media="screen" />
        <script type="text/javascript" language="javascript"
src="/templates/defaultbluelight/javascript/blockresizetowindow.js"></script>   
        
        <script type="text/javascript" language="javascript"
src="/templates/defaultbluelight/javascript/blockresizetowindow.js"></script>
        <script type="text/javascript" language="javascript"
src="/templates/defaultbluelight/javascript/AWB_Utilites.js"></script>  

        <script type="text/javascript">
                djConfig = {
                        isDebug: false,
                        baseRelativePath: "js/dojo",
                        preventBackButtonFix: false,
                        parseWidgets: false,
                        disableFlashStorage: true
                };
        </script>
        <script type="text/javascript" src="js/dojo/dojo.js"></script>

</head>

<body id="repDocument" jwcid="@Body">
        
         RepTopBar Component 
        PageTitleWithMenu
        
        <div id="contentArea">
                <div id="leftColumn">
                        Left Column
                </div>  
                 
                <div id="rightColumn">
                        <!-- <div jwcid="editArticleText">Article Title</div>  
-->
                        <div jwcid="@Any" id="searchBlock">
                                <div id="searchBlockElement" >
                                
                                 
                                
                                 
                        </div>
                        <div jwcid="@If" condition="ognl:isSearchSelected">
                                        <div class="searchBlock">
                                                <form jwcid="[EMAIL 
PROTECTED]:AjaxForm" delegate="bean:delegate">
                                                        
                                                        <div jwcid="@If" 
condition="ognl:beans.delegate.hasErrors">
                                                                <div 
style="color:red">
                                                                        
                                                                </div>
                                                        </div>
                                                        
                                                        <table width="100%" 
border="0" >
                                                                <tr>
                                                                        <th 
align="left">Client First Name:</th>
                                                                        
<th>Client Last Name:</th>
                                                                </tr>
                                                                <tr>
                                                                        
<td><input jwcid="[EMAIL PROTECTED]" displayName="First Name"
value="ognl:repDocumentSearchDTO.firstName" size="40"/></td>
                                                                        
<td><input jwcid="[EMAIL PROTECTED]" displayName="Last Name"
value="ognl:repDocumentSearchDTO.lastName" size="40"/></td>
                                                                </tr>
                                                                <tr>
                                                                        
<th>Client's SSN:</th>
                                                                        <th>Rep 
Number:</th>
                                                                </tr>
                                                                <tr>
                                                                        <td>
                                                                                
<input jwcid="[EMAIL PROTECTED]"
                                                                         
formatter="formatter:mask,format=###-##-####"
                                                                         
value="ognl:repDocumentSearchDTO.ssn"
                                                                         
displayName="Social Security Number" />
                                                                        </td>
                                                                        <td>
                                                                        <!--   
-->
                                                                        </td>
                                                                </tr>
                                                                <tr>
                                                                        
<th>Account Type:</th>
                                                                        
<th>File Type:</th>
                                                                </tr>
                                                                <tr>
                                                                        
<td></td>
                                                                        <td>
                                                                                
                                                                        </td>
                                                                </tr>
                                                                <tr>
                                                                        
<th>Date Created:</th>
                                                                        
<th>Date Changed:</th>
                                                                </tr>
                                                                <tr>
                                                                        
<td></td>
                                                                        
<td></td>
                                                                </tr>
                                                                <tr>
                                                                        <th 
colspan="2">Rep Comments:</th>
                                                                </tr>
                                                                <tr>
                                                                        <td 
colspan="2"><input jwcid="[EMAIL PROTECTED]"
displayName="Rep Comments" value="ognl:repDocumentSearchDTO.repComments"
size="80"/></td>
                                                                </tr>
                                                        </table>
                                                        <div 
clas="button_group">
                                                                <input 
jwcid="[EMAIL PROTECTED]:AjaxSubmit" value="Clear Form"
action="listener:onClearSearchForm" 
                                                                        
updateComponents="ognl:{'searchBlock'}" 
                                                                        
effects="template:{searchForm:'[255,255,184], 500, 500'}" />  
                                                                <input 
jwcid="[EMAIL PROTECTED]:AjaxSubmit" value="Search"
action="listener:onSearch" 
                                                                        
updateComponents="ognl:{'showSearchResult'}" 
                                                                        
effects="template:{searchForm:'[255,255,184], 500, 500'}" />
                                                        </div>
                                                </form> 
                                                <p style="color:#666;">Rendered 
on: .</p>
                                        </div>
                        </div>
                        
                        <div jwcid="@Any" id="showSearchResult">
                                        <div jwcid="@If" 
condition="ognl:isSearchButtonClicked">
                                                <div jwcid="@Any" 
id="searchResult">
                                                        <div 
id="searchResultElement">
                                                        
                                                         
                                                        
                                                         
                                                </div>
                                                <div jwcid="@If" 
condition="ognl:isSearchResultSelected">
                                                                <div 
class="searchBlock">
                                                                        <div 
jwcid="reportTable" title="Demo Report"/>

                                                                            
<!-- provide a div which will be displayed by event handler
during work-->
                                                                            
<div id="progress"
style="position:absolute;font-size:36px;padding:30px;background-color:black;color:white;display:none;width:250px;">Processing...</div>
                                                                            
<script type="text/javascript">
                                                                                
dojo.addOnLoad(function() {
                                                                        
                                                                                
    dojo.event.connect(dojo.widget.byId("reportTable"), 
                                                                                
        "onStartProcessing", 
                                                                                
        function() {
                                                                                
            var progNode = dojo.byId("progress");
                                                                                
            var parent = progNode.parentNode;
                                                                                
            dojo.style.setDisplay(progNode, "block");
                                                                                
            dojo.style.setOpacity(progNode, .7);
                                                                                
            var left = (dojo.style.getContentWidth(parent)
- dojo.style.getOuterWidth(progNode)) / 2;
                                                                                
            if (left > 0) {
                                                                                
                progNode.style.left = left + "px";
                                                                                
            }
                                                                                
            progNode.style.top =
dojo.style.getTotalOffset(parent, "top", true) + 50 + "px";
                                                                                
        });
                                                                        
                                                                                
    dojo.event.connect(dojo.widget.byId("reportTable"), 
                                                                                
        "onStopProcessing", 
                                                                                
        function() {
                                                                                
            var progNode = dojo.byId("progress");
                                                                                
            dojo.lfx.fadeHide(progNode, 800).play();
                                                                                
        });
                                                                        
                                                                                
    });
                                                                            
</script>
                                                                </div>
                                                        </div>
                                                </div>
                                        </div>
                                </div>
                                
                                
                        </div>
                </div>
        </div>
        <div id="partialWait">
                 templates/defaultbluelight/images/wait.gif Processing...
        </div>
</body>
</html>


the java file:

package com.mycompany.ui.web.action.securepages.rep;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.tacos.ajax.components.grid.GridColumn;
import net.sf.tacos.ajax.components.grid.GridColumnModel;

import org.acegisecurity.annotation.Secured;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.annotations.InjectState;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.form.IPropertySelectionModel;
import org.apache.tapestry.form.StringPropertySelectionModel;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.valid.ValidationDelegate;

import com.investacorp.business.dtos.RepDocumentSearchDTO;
import com.investacorp.business.service.appuser.AppUserService;
import com.investacorp.business.service.rep.RepService;
import com.investacorp.ui.web.action.SessionUserInfo;

@Secured({"ROLE_REP_ADMIN", "ROLE_REP"})
public abstract class RepDocumentPage extends BasePage implements
PageBeginRenderListener {
        
        /* CONSTANTS */
        public static final String PAGE_NAME = "RepDocumentPage";
        public static final String TOP_BAR_NAME = "Document Management System";
        public static final DateFormat DATE_FORMAT =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
        private static Logger log = 
LoggerFactory.getLogger(RepDocumentPage.class);
        
        /* INJECTED OBJECTS */
        @InjectState("sessionuserinfo")
        public abstract SessionUserInfo getSessionUserInfo();

        @InjectObject("spring:repService")
        public abstract RepService getRepService();
        
        @InjectObject("spring:appUserService")
        public abstract AppUserService getAppUserService();
        
        @Bean
        public abstract ValidationDelegate getDelegate();
        
        /* ABSTRACT METHODS */
        @Persist("client")
        public abstract boolean getIsSearchSelected();
        public abstract void setIsSearchSelected(boolean b);
        @Persist("client")
        public abstract boolean getIsSearchButtonClicked();
        public abstract void setIsSearchButtonClicked(boolean b);
        @Persist("client")
        public abstract boolean getIsSearchResultSelected();
        public abstract void setIsSearchResultSelected(boolean b);
        
        public abstract RepDocumentSearchDTO getRepDocumentSearchDTO();
        public abstract void setRepDocumentSearchDTO(RepDocumentSearchDTO o);
        
        /* PAGE BEGIN RENDER */
        public void pageBeginRender(PageEvent event) {
                RepDocumentSearchDTO repDoc = new RepDocumentSearchDTO();
                setRepDocumentSearchDTO(repDoc);
        }
        
        public String getCurrentTopBarName() {
                return getSessionUserInfo().getRepSite().getCompanyName() + "-"+
TOP_BAR_NAME;
        }
        
        public IPropertySelectionModel getRepNumSelectModel() {
                AppUser appUser =
getAppUserService().getUserByPrimaryKey(getSessionUserInfo().getUserName());
                Rep rep = getRepService().getRepByRepNum(appUser.getRepNum());
                
                /// TODO : change to get list of visible reps and rep first 
name and last
name
                List<Rep> visibleRepList =
getRepService().getRepByProdGroup(rep.getRepNum());
                String[] visibleRepSelectArray = null;
                if (visibleRepList != null && visibleRepList.size() > 0) {
                        visibleRepSelectArray = new 
String[visibleRepList.size() + 1];
                visibleRepSelectArray[0] = RepDocumentSearchDTO.SELECT_REP_NUM;
                        int i = 1;
                        for (Rep repElement :visibleRepList) {
                                visibleRepSelectArray[i] = 
repElement.getRepNum();
                                i++;
                        }
                }
                
                System.out.println("leaving getRepNumSelectModel()");
                
                return new StringPropertySelectionModel(visibleRepSelectArray);
        }
        
        public IPropertySelectionModel getFileTypeSelectModel() {       
                String[] fileTypeSelectArray = new String[3];
                fileTypeSelectArray[0] = RepDocumentSearchDTO.SELECT_FILE_TYPE;
                fileTypeSelectArray[1] = "Image";
                fileTypeSelectArray[2] = "PDF";
                return new StringPropertySelectionModel(fileTypeSelectArray);
        }
        
        public IPropertySelectionModel getAccountTypeSelectModel() {    
                //TODO : get the accounts from the db...
                String[] accountTypeSelectArray = new String[3];
                accountTypeSelectArray[0] = 
RepDocumentSearchDTO.SELECT_ACCOUNT_NUM;
                accountTypeSelectArray[1] = "IC12345";
                accountTypeSelectArray[2] = "IC23445";
                return new StringPropertySelectionModel(accountTypeSelectArray);
        }
        
         public GridColumnModel getGridColumns() { 
                return new GridColumnModel(
                        Arrays.asList(new GridColumn[] {
                             new GridColumn("stringColumn", "A String", new
Integer(150), true, false, 
                                     GridColumn.STRING_TYPE, "textClass", 
"bottom",
"center", "textClass", false),   
                             new GridColumn("intColumn", "An Integer", new
Integer(150), true, false, 
                                     GridColumn.NUMBER_TYPE, "#,##0", null, 
null,
"numberClass", false),   
                             new GridColumn("floatColumn", "A Float", new
Integer(150), true, false, 
                                     GridColumn.NUMBER_TYPE, "#,##0.00", null,
null, "numberClass", false),   
                             new GridColumn("dateColumn", "A Date", new
Integer(150), true, false, 
                                     GridColumn.DATE_TYPE, "%Y/%m/%d", "bottom",
"center", "dateClass", false),   
                        })
                );
            }
            
            public Object getGridData()  { 
                List results = new ArrayList();
                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd",
getLocale());
                for (int i = 0; i < 100; i++) {
                    Map map = new HashMap();
                    map.put("stringColumn", "String " + i);
                    map.put("intColumn", new Integer(i * 10));
                    map.put("floatColumn", "" + ((i * 100) + (float) ((float) i 
/
(float) (i + 1))));
                    Calendar cal = Calendar.getInstance();
                    cal.add(Calendar.DATE, i);
                    map.put("dateColumn", dateFormat.format(cal.getTime()));
                    results.add(map);
                }
                return results;
            }    
            
            public boolean getInitSortOrder()
            {
                return true;
            }     
            
            public String getInitSortColumn()
            {
                return "intColumn";
            }    
            
            public Map getTotalRow()
            {
                Map map = new HashMap();
                map.put("stringColumn", null);
                map.put("intColumn", new Integer(123456789));
                map.put("floatColumn", new Double(1234567.89));
                map.put("dateColumn", null);
                return map;
            }     

            public String getInfo()
            {
                return "This is an informative string that can be generated on 
the
fly";
            }
        
        public void onSearchForm(IRequestCycle cycle){
                if (getIsSearchSelected()) {
                        setIsSearchSelected(false);
                } else {
                        setIsSearchSelected(true);
                }
        }
        
        public void onClearSearchForm(IRequestCycle cycle) {
                System.out.println("inside onClearSearchForm");
                setRepDocumentSearchDTO(new RepDocumentSearchDTO());
        }
        
        public void onSearchResult(IRequestCycle cycle) {
                if (getIsSearchResultSelected()) {
                        setIsSearchResultSelected(false);
                } else {
                        setIsSearchResultSelected(true);
                }
        }
        
        public String onSearch(IRequestCycle cycle) {
                System.out.println("Inside onSearch()" + 
getRepDocumentSearchDTO());
                ValidationDelegate delegate = getDelegate();
                
                System.out.println("isHavingSearchParametersSet() = " +
getRepDocumentSearchDTO().isHavingSearchParametersSet());
                if (!getRepDocumentSearchDTO().isHavingSearchParametersSet()) {
                        /* No field set for searching. Set error message */
                        delegate.setFormComponent(null);
                        delegate.record("No search parameters set. You must 
input at least 1
search parameter!", null);
                } else {
                        setIsSearchButtonClicked(true);
                        setIsSearchResultSelected(true);
                }
                return null;
        }
        
}



-- 
View this message in context: 
http://www.nabble.com/Need-help-with-Tacos-and-validation-tf3671067.html#a10269715
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to