10 Replies Latest reply on Jul 7, 2015 7:09 PM by Timo Hahn

    af:table hide a row

    kiran mahanthy

      Hi All,

       

      I am using jdev 11.1.1.7.0

       

      I have a list of DTO in my bean (NOT VO based ). Its a web service based one .

      I have shown this list in the page as a Table (  <af:table value="#{pageFlowScope.testBean.phoneInfoList}" )

      In the table , I have a column with a Button "Donot Show" . I am setting a DTO variable showRow as false in the action event of the button for the current row.

      I have added a rendered condition on the inputText column of the table and the rendered condition is working fine. The data is not shown but how ever , a blank row is shown.

      How can we hide the entire row itself??

       

        <af:table value="#{pageFlowScope.testBean.phoneInfoList}"

                            var="row" emptyText="#{ssBundle.NO_DATA_TO_DISPLAY_LBL}"

                            autoHeightRows="0"

                            width="70%"

                            columnStretching="multiple" rowBandingInterval="0"

                            rowSelection="single" contentDelivery="immediate"

                            id="wssmpt1"

                        binding="#{pageFlowScope.testBean.phoneTableBinding}"

                        varStatus="rowStatus">

      <af:column sortable="false"

                               headerText="#{''}" id="wssmpc3" width="2"

                               rowHeader="true" >

                      <af:inputText value="#{row.sequence}"  rendered="#{!row.isRowDeleted}"

                                    simple="true" label="#{''}"

                                    id="wssmpit1"/>

                    </af:column>

                    <af:column headerText="#{ssBundle.ACCOUNT_PHONETYPE_LBL}"

                               width="30%" align="center" id="amupptclm"

                               clientComponent="true">

                      <af:selectOneChoice value="#{row.phoneType}" rendered="#{!row.isRowDeleted}"

                                          inlineStyle="padding:5px; white-space:nowrap;"

                                          editable="always" valuePassThru="true"

                                          label="#{''}" required="true" id="wssmpsoc1"

                                          autoSubmit="true"

                                          valueChangeListener="#{pageFlowScope.testBean.selectPhoneType}"

                                          requiredMessageDetail="#{ssBundle.ACCOUNT_PHONETYPE_REQUIRED_LBL}">

                        <f:attribute name="sequence" value="#{row.sequence}"/>

                        <f:selectItems value="#{pageFlowScope.testBean.phoneTypes}"

                                       id="wssmpsi1"/>

                      </af:selectOneChoice>

                    </af:column>

                    <af:column headerText="#{ssBundle.ACCOUNT_PHONENO_LBL}"

                               width="30%" align="start" id="wssmpc5">

                      <af:panelLabelAndMessage id="wssmpplm1" for="wssmpit7">

                        <af:inputText value="#{row.phoneNumber}" required="true" rendered="#{!row.isRowDeleted}"

                                      requiredMessageDetail="#{ssBundle.ACCOUNT_PHONENUM_REQUIRED_LBL}"

                                      columns="14" id="wssmpit7" simple="true" autoSubmit="true"

                                      binding="#{pageFlowScope.testBean.setDefaultFormat}"

                                      valueChangeListener="#{pageFlowScope.testBean.phoneNumberChanged}">

                                        <af:clientListener method="resetInputText" type="click"/>

                          

                        </af:inputText>

                       

                      

                        <f:facet name="end">

                          <af:outputLabel value="#{row.phoneNumberFormat}" rendered="#{!row.isRowDeleted}"

                                          partialTriggers="wssmpsoc1" id="ol1"/>

                        </f:facet>

                  

                      </af:panelLabelAndMessage>

                    </af:column>

                    <af:column headerText="#{ssBundle.REMOVE_LBL}" align="center"

                               width="10%" id="ammpac1">

                  

                        <af:commandImageLink partialSubmit="true" rendered="#{!row.isRowDeleted}"

                                           shortDesc="#{ssBundle.ACCOUNT_PHONE_REMOVE_LBL}"

                                           icon="/adf/images/delete_ena.png"

                                           actionListener="#{pageFlowScope.testBean.removePhone}"

                                           id="ammprpbtn" immediate="true">

                        <f:attribute name="sequence" value="#{row.sequence}"/>

                      </af:commandImageLink>

                    </af:column>

                  </af:table>

       

      table.png

      I have deleted the 2nd row. But the row is still visible

        • 1. Re: af:table hide a row
          Timo Hahn

          You should remove the row from the list and store it in another list (the deleted list). Then you can act on the deleted list later on, e.g. removing the row.

           

          Timo

          • 2. Re: af:table hide a row
            kiran mahanthy

            Hi Timo ,

             

            Thank you for the reply

            I have tried removing the row. Some thing weird happens and always the last row in the table is only getting deleted . I have tried various approaches for this but no success.

            I have come up with this solution after trying all that ..

            Is there any way we can hide the entire row ?? The problem is , I dont have an iterator as well or I could have changed the row state to deleted.

            • 3. Re: af:table hide a row
              kiran mahanthy

              You can check my post about removing the row that i had posted earlier

               

              ADF table remove row

              • 4. Re: Re: af:table hide a row
                Timo Hahn

                Your code is mostly OK. Only one thing will cause trouble, the

                phonelist.remove(currentIndex);

                You should use

                phonelist.remove(currentIndex.intValue());

                Problem is that the ArrayList.remove is overloaded for Object  type parameter and int type parameter. When you pass the currentIndex it's used as an object to find the object to remove. As it can't be found, nothing is removed.

                use

                    private void initList() {

                        if (phoneInfoList != null) {

                            phoneInfoList.clear();

                        }

                        phoneInfoList = new ArrayList<PhoneInfoDTO>();

                        PhoneInfoDTO dto1 = new PhoneInfoDTO();

                        dto1.setSequence(1);

                        dto1.setPhoneNumber("(408)250-0438");

                        dto1.setPhoneType("BUSN");

                        phoneInfoList.add(dto1);

                        PhoneInfoDTO dto2 = new PhoneInfoDTO();

                        dto2.setSequence(2);

                        dto2.setPhoneNumber("(408)250-0439");

                        dto2.setPhoneType("CELL");

                        phoneInfoList.add(dto2);

                        PhoneInfoDTO dto3 = new PhoneInfoDTO();

                        dto3.setSequence(3);

                        dto3.setPhoneNumber("(408)250-0430");

                        dto3.setPhoneType("SMS");

                        phoneInfoList.add(dto3);

                        PhoneInfoDTO dto4 = new PhoneInfoDTO();

                        dto4.setSequence(4);

                        dto4.setPhoneNumber("(408)250-5678");

                        dto4.setPhoneType("FAX");

                        phoneInfoList.add(dto4);

                        logger.info("List initalized");

                    }

                   public List<PhoneInfoDTO> getPhoneInfoList() {

                        // layz init list

                        if (phoneInfoList == null) {

                            initList();

                        }

                        return phoneInfoList;

                    }

                 

                    public void onRemoveAction(ActionEvent actionEvent) {

                        Integer currentIndex = getCurrentSelectedIndex();

                        logger.info("Removing with index : >> " + currentIndex);

                        logger.info("Removing with size : >> " + phoneInfoList.size());

                        logger.info("Value in List ** " + phoneInfoList.get(currentIndex).getSequence() + " phone " + phoneInfoList.get(currentIndex).getPhoneType());

                        phoneInfoList.remove(currentIndex.intValue());

                        logger.info("size after removing : >> " + phoneInfoList.size());

                        UIComponent ui = (UIComponent)actionEvent.getSource();

                        AdfFacesContext.getCurrentInstance().addPartialTarget(ui.getParent().getParent().getParent());

                    }

                and it should work.

                 

                Timo

                • 5. Re: Re: af:table hide a row
                  kiran mahanthy

                  Hi Timo

                   

                  I tried your approach as well .. mentioned above .. Its not working. by default , the remove is removing only the last row ..

                  • 6. Re: Re: af:table hide a row
                    Timo Hahn

                    I have a working sample

                     

                    Gimme some time, I'll upload it later.

                     

                    Timo

                    • 7. Re: Re: af:table hide a row
                      kiran mahanthy

                      Sure !! Thanks a ton

                      • 8. Re: Re: af:table hide a row
                        Timo Hahn

                        You can download the sample from https://github.com/tompeez/BlogPoJoTableDeleteRow/archive/develop.zip

                        It doesn't need a model project or DB connection. Just run the index page and click a remove button in the table.

                         

                        Timo

                        • 9. Re: Re: af:table hide a row
                          kiran mahanthy

                          Thanks Timo ! I have replicated this code .. it works

                          • 10. Re: af:table hide a row
                            Timo Hahn

                            Welcome, then close the thread please.

                             

                            Timo