4 Replies Latest reply on Nov 18, 2009 11:10 AM by Harald Höhn

    <rich:dataTable> with dynamic context menu don't work corect

    Harald Höhn Newbie

      Hi,

      I have a problem to set an context menu to an datatable with dynamic menu entries. I wont to render/notreder or enable/disable context menu items depending on each table entry type. I have testet this issue in different way, but the result is allways the same. The mdynamic menu entries ar enabled/disabled for all table entrys.

      Here is my sample:


       <h:form>
       <rich:dataTable id="openAlarmTable_id"
       columnsWidth="200px,140px,120px,*,100px"
       onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
       cellpadding="0" cellspacing="0" width="1050px" border="0"
       var="record" value="#{MyBean.entries}">
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column>
       // all column header definitions
       </rich:column>
       </rich:columnGroup>
       </f:facet>
       <rich:column
       // all column output definitions
       </rich:column>
       <rich:componentControl event="onRowClick" for="contextmenu_table_id" operation="show">
       <f:param value="#{record.obid}" name="obid"/>
       <f:param value="#{record.mapId == -1}" name="nomap"/>
       <f:param value="#{record.mapId}" name="mapid"/>
       </rich:componentControl>
       </rich:dataTable>
       </h:form>
      
      ... other definitions
      
       <h:form>
       <rich:contextMenu id="contextmenu_table_id" submitMode="ajax">
       <rich:menuItem>
      
       <a4j:actionparam name="show_ymptoms" value="true" assignTo="#{AlarmTableBean.showSymptoms}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Hide Symptoms" reRender="state_tree_id,openAlarmTable_id" >
       <a4j:actionparam name="hide_symptoms" value="false" assignTo="#{AlarmTableBean.showSymptoms}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Show Acknowledged" reRender="state_tree_id,openAlarmTable_id" >
       <a4j:actionparam name="show_ymptoms" value="true" assignTo="#{AlarmTableBean.showAcknowledged}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Hide Acknowledged" reRender="state_tree_id,openAlarmTable_id" >
       <a4j:actionparam name="hide_symptoms" value="false" assignTo="#{AlarmTableBean.showAcknowledged}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Acknowledge" reRender="state_tree_id,openAlarmTable_id" rendered="#{SaveBean.nocUser}">
       <a4j:actionparam name="alarmId" value="{obid}" assignTo="#{AcknowledgeDataBean.acknowledgeAlarm}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Unacknowledge" reRender="state_tree_id,openAlarmTable_id" rendered="#{SaveBean.nocUser}">
       <a4j:actionparam name="alarmId" value="{obid}" assignTo="#{AcknowledgeDataBean.unAcknowledgeAlarm}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Ignore Alarm" reRender="state_tree_id,openAlarmTable_id" >
       <a4j:actionparam name="alarmId" value="{obid}" assignTo="#{AlarmTableBean.ignoreAlarm}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Reset Ignore List" reRender="state_tree_id,openAlarmTable_id" >
       <a4j:actionparam name="resetList" value="true" assignTo="#{AlarmTableBean.resetIgnoreList}"/>
       <a4j:actionparam name="init" value="false" assignTo="#{AlarmTableBean.init}"/>
       </rich:menuItem>
       <rich:menuItem value="Acknowledge Dialog" reRender="modalackpanel" rendered="#{SaveBean.nocUser}" oncomplete="#{rich:component('modalackpanel')}.show()" >
       <a4j:actionparam name="alarmId" value="{obid}" assignTo="#{AcknowledgeDataBean.alarmId}"/>
       </rich:menuItem>
       <rich:menuItem value="Jump to Weathermap" disabled="{isweathermap}" submitMode="none"
       onclick="document.location.href='/html/weatherMapDisplayView.jsf?init=false&amp;map={weathermapid}'" />
       </rich:contextMenu>
       </h:form>
      
      
      


        • 1. Re: <rich:dataTable> with dynamic context menu don't work co
          Harald Höhn Newbie

          Sorry, i have saved this form topic not finished. this is the correct Forum entry:

          Hi,

          I have a problem to set an context menu to an datatable with dynamic menu entries. I wont to render/notreder or enable/disable context menu items depending on each table entry type. I have testet this issue in different way, but the result is allways the same. The mdynamic menu entries ar enabled/disabled for all table entrys.

          Here is my sample:


           <a4j:form>
           <rich:dataTable id="openAlarmTable_id"
           columnsWidth="200px,140px,120px,*,100px"
           onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
           onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
           cellpadding="0" cellspacing="0" width="1050px" border="0"
           var="record" value="#{MyBean.entries}">
           <f:facet name="header">
           <rich:columnGroup>
           <rich:column>
           // all column header definitions
           </rich:column>
           </rich:columnGroup>
           </f:facet>
           <rich:column
           // all column output definitions
           </rich:column>
           <rich:componentControl event="onRowClick" for="contextmenu_table_id" operation="show">
           <f:param value="#{record.obid}" name="obid"/>
           <f:param value="#{record.mapId == -1}" name="nomap"/>
           <f:param value="#{record.mapId}" name="mapid"/>
           </rich:componentControl>
           </rich:dataTable>
           </a4j:form>
          
          ... other definitions
          
           <h:form>
           <rich:contextMenu id="contextmenu_table_id" submitMode="ajax">
           <rich:menuItem>
           // static menu entries definition
           </rich:contextMenu>
           <rich:menuItem value="Jump to Map" disabled="{nomap}" submitMode="none"
           onclick="document.location.href='/html/mapDisplayView.jsf?init=false&map={mapid}'" />
           </rich:contextMenu>
           </h:form>
          
          
          


          I have testes the parameter in the source and in the bean. the parameter are always correct. All 3 parameter will be set correctly.

          Sample for a table entry which should enable the menu entry:(i can check this parameter in the HTML soure and they are correct but the handling is wrong)

          obid: 1000
          nomap: false
          mapid: 100

          Sample for a tableentry which schould disable the menu entry: (i can check this parameter in the HTML soure and they are correct but the handling is wrong)

          obid: 2000
          nomap: true
          mapid: -1

          The link in the menu item "Jump to Map" will be called correctly. But the element will not disabled if the mapid = -1.

          I think it is a bug in the Menu item emelement that you can't use boolean f:param element values as displayed or rendered attribute entry.

          Please give me a hint.


          • 2. Re: <rich:dataTable> with dynamic context menu don't work co
            Ilya Shaikovsky Master

            yes, disabled attribute evaluated at the moment when menu encoded. So it can't be changed with client side macrosubstitutions as you trying.. And I can't cvalify this as bug.. Just non-existent feature.

            • 3. Re: <rich:dataTable> with dynamic context menu don't work co
              Nick Belaevski Master

              Hi,

              You can render both and then hide/show disabled/enabled item using CSS.

              • 4. Re: <rich:dataTable> with dynamic context menu don't work co
                Harald Höhn Newbie

                 

                "nbelaevski" wrote:
                Hi,

                You can render both and then hide/show disabled/enabled item using CSS.


                Thank you for this idea. It works fine.