4 Replies Latest reply on Dec 27, 2007 11:19 AM by eee eee

    scrollabledatatable and ie6

    shooali Newbie

      Hello,

      I have started using scrollableDataTable component and I am having some problems.
      Currently, it works only for IE7 and on IE6 it stuck the browser and then the browser crashes. The problem occurs only when there are no rows to show, if there is at least one row then it works fine.

      If I just remove the scrollableDataTable from the page, all works fine.

      I am using richfaces 3.1.2, myfaces 1.2.0, tomahawk 1.1.6, facelets 1.1.13 and Tomcat 6.

      Attached please find the relevant xhtml code and java code. plz help.

      thanks.

      xhtml:


       <t:saveState value="#{manageRulesStageBean}" />
      
      
       <table cellpadding="0" cellspacing="0" class="size100">
       <tr>
       <td style="height: 45%;">
       <rich:scrollableDataTable
       id="rulesList"
       binding="#{manageRulesStageBean.rulesDataTable}"
       selection="#{manageRulesStageBean.rulesSelection}"
       value="#{manageRulesStageBean.webRules}"
       var="rule" height="100%" width="100%"
       frozenColCount="3"
       first="0"
       rowClasses="evenRow,oddRow"
       styleClass="tablestyle"
       >
       <a4j:support
       event="onselectionchange"
       reRender="rule_summary,edit_rule_btn,duplicate_rule_btn,enable_rule_btn,disable_rule_btn,delete_rule_btn" />
      
       <rich:column sortExpression="#{rule.name}">
       <f:facet name="header">
       <h:outputText
       id="ruleNameHeader"
       value="#{messages['POLICY.WIZARD.LABEL.RULE_NAME']}"/>
       </f:facet>
       <h:outputText id="ruleName" value="#{rule.name}"/>
       </rich:column>
       <rich:column sortExpression="#{rule.description}" width="500px">
       <f:facet name="header">
       <h:outputText
       id="ruleShortDescriptionHeader"
       value="#{messages['POLICY.WIZARD.LABEL.DESCRIPTION']}"/>
       </f:facet>
       <h:outputText id="ruleShortDescription" value="#{rule.description}" />
       </rich:column>
       <rich:column sortExpression="#{rule.priority}">
       <f:facet name="header">
       <h:outputText
       id="rulePriorityHeader"
       value="#{messages['POLICY.WIZARD.LABEL.RULE_PRIORITY']}"/>
       </f:facet>
       <h:panelGroup id="imageAndPriorityGroup">
       <h:graphicImage id="rulePriorityImg" value="#{rule.priorityIcon}" />
       <h:outputText id="rulePriority"
       value=" #{messages[rule.priority.fullName]}" />
       </h:panelGroup>
       </rich:column>
       </rich:scrollableDataTable>
       </td>
       </tr>
       <tr>
       <td style="height: 1%;">
       <h:panelGroup id="rules_buttons" style="display: block; vertical-align: middle;">
      
       <span class="submit_span" style="float: left">
       <a4j:commandButton
       id="create_rule_btn"
       immediate="true"
       reRender="addRuleWizardPanel"
       oncomplete="openAddRuleWizardMP()"
       actionListener="#{manageRulesStageBean.onCreateNewRule}"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_CREATE_RULE']}"
       styleClass="submit_btn" />
      
       <span style="width: 10px;" />
       <a4j:commandButton
       id="edit_rule_btn"
       immediate="true"
       disabled="#{!manageRulesStageBean.oneRuleSelected}"
       actionListener="#{manageRulesStageBean.onEditRule}"
       reRender="editRuleWizardPanel"
       oncomplete="openEditRuleWizardMP()"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_EDIT_RULE']}"
       styleClass="submit_btn" />
      
       <span style="width: 10px;" />
       <a4j:commandButton
       id="delete_rule_btn" type="submit"
       disabled="#{!manageRulesStageBean.atLeastOneRuleSelected}"
       actionListener="#{manageRulesStageBean.onDeleteRule}"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_DELETE_RULE']}"
       styleClass="submit_btn"
       onsubmit="return confirmBeforeSubmit('#{messages['WARNING.ABOUT_TO_DELETE_RULES']}');"
       oncomplete="refreshRulesList();"/>
       <span style="width: 10px;" />
       <a4j:commandButton
       id="duplicate_rule_btn" immediate="true" type="submit"
       disabled="#{!manageRulesStageBean.oneRuleSelected}"
       actionListener="#{manageRulesStageBean.onDuplicateRule}"
       oncomplete="refreshRulesList();"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_DUPLICATE_RULE']}"
       styleClass="submit_btn" />
      
       <span style="width: 10px;" />
       <h:commandButton
       id="enable_rule_btn" type="submit"
       disabled="#{!manageRulesStageBean.allSelectedDisabled}"
       actionListener="#{manageRulesStageBean.onEnableRule}"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_ENABLE_RULE']}"
       styleClass="submit_btn" /> <span style="width: 10px;" /> <h:commandButton
       id="disable_rule_btn" type="submit"
       disabled="#{!manageRulesStageBean.allSelectedEnabled}"
       actionListener="#{manageRulesStageBean.onDisableRule}"
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.BUTTON_DISABLE_RULE']}"
       styleClass="submit_btn" /> </span> <span style="float: right"> <h:outputText
       value="#{manageRulesStageBean.numOfRules}" class="txt_bold" /> <span> </span>
       <h:outputText
       value="#{messages['POLICY.WIZARD.STAGE.MANAGE_RULES.LABEL_SUFFIX']}"
       class="txt_reg" /> </span>
       </h:panelGroup></td>
       </tr>
       <tr>
       <td class="detail_panel" style="height: 20%;">
       <h3>#{messages['POLICY.WIZARD.LABEL.RULE_SUMMARY']}</h3>
      
       <div class="detail_panel"><h:panelGroup id="rule_summary">
       <a4j:repeat id="rule_summary_repeat" var="fragment"
       value="#{manageRulesStageBean.selectedRuleSummaryFragments}">
       <h:outputText rendered="#{fragment.typeText}"
       value="#{fragment.text}" />
       <h:outputText rendered="#{fragment.typeReference}"
       value="#{fragment.text}" style="font-weight: bold" />
      
       <!-- In this page, the "blank" option is needed to support rules that come from policy templates -->
       <h:outputText rendered="#{fragment.typeEmptyReference}"
       value="______" />
       <t:htmlTag rendered="#{fragment.typeSeperator}" value="br" />
       </a4j:repeat>
       </h:panelGroup></div>
       </td>
       </tr>
       </table>
      


      java code:

      public class ManageRulesStageBean extends
       PolicyWizardStageBean {
      
       private List<WebRuleBean> webRules;
       private SimpleSelection rulesSelection;
       private HtmlScrollableDataTable rulesDataTable;
      
      
       @SuppressWarnings("unchecked")
       public ManageRulesStageBean(){
       super();
       Comparator comparator = new Comparator()
       {
       public int compare(Object o1, Object o2)
       {
       WebRuleBean c1 = (WebRuleBean) o1;
       WebRuleBean c2 = (WebRuleBean) o2;
       return sortAscending ? c1.getRuleName().compareTo(c2.getRuleName()) : c2.getRuleName()
       .compareTo(c1.getRuleName());
       }
       };
       Collections.sort(getWebRules(), comparator);
      
      
       }
      
      
       public void setInit(boolean init){
       if(init){
       //if there is at least one rule, select the first
       if(this.getWebRules().size()>0){
       selectFirstRow();
       }
       }
       }
      
       private void selectFirstRow(){
       SimpleSelection defaultSelection = new SimpleSelection();
       defaultSelection.addKey(new SimpleRowKey(0));
       this.setRulesSelection(defaultSelection);
       if(this.getRulesDataTable()!=null){
       this.getRulesDataTable().setSelection(defaultSelection);
       }
       }
      
      
      
       /**
       * Get the first of the selected rules.
       * @return null if none selected
       */
       private WebRuleBean getFirstSelectedRule(){
       WebRuleBean firstSelectedRule = null;
      
       if(getSelectedRules().size()>0){
       firstSelectedRule = getSelectedRules().get(0);
       }
      
       return firstSelectedRule;
       }
      
       /**
       * Get a list of the selected rules
       * @return empty list if none selected
       */
       @SuppressWarnings("unchecked")
       private List<WebRuleBean> getSelectedRules(){
       List<WebRuleBean> selectedRules = new ArrayList<WebRuleBean>();
      
       if(this.getRulesSelection()!=null && webRules.size()>0){
      
       Iterator<SimpleRowKey> selectedKeysIterator = this.getRulesSelection().getKeys();
      
       // if at least one selected
       if(selectedKeysIterator.hasNext()){
       //take the first selected
       SimpleRowKey firstSelectedKey = selectedKeysIterator.next();
       selectedRules.add(webRules.get(firstSelectedKey.intValue()));
       }
      
       }
      
       return selectedRules;
      
       }
      
       public List<WebRuleBean> getWebRules() {
       if (webRules == null) {
       webRules = getPolicyEditingSessionBean().getEditedPolicy().getRules();
       }
      
       //if there is only one rule, select the first
       if(webRules.size()==1){
       selectFirstRow();
       }
      
       return webRules;
       }
      
      
       public void setWebRules(List<WebRuleBean> webRules) {
       getPolicyEditingSessionBean().getEditedPolicy().setRules(webRules);
       this.webRules = webRules;
       }
      
       public SimpleSelection getRulesSelection() {
       return rulesSelection;
       }
      
       public void setRulesSelection(SimpleSelection rulesSelection) {
       this.rulesSelection = rulesSelection;
       }
      
      
       public HtmlScrollableDataTable getRulesDataTable() {
       return rulesDataTable;
       }
      
      
       public void setRulesDataTable(HtmlScrollableDataTable rulesDataTable) {
       this.rulesDataTable = rulesDataTable;
       }
      
      }