14 Replies Latest reply on Oct 1, 2014 7:04 AM by Asim Shaikh

    divide column in to two columns

    Asim Shaikh Novice

      I have Attachment column in that I am showing Uploaded files .Now  I need to show column with two different files having two different names 1 is Download 2 is Ammended Download how can I do that

       

      <rich:column style="width:15%;" id="LicenceDataclm3">

                                          <f:facet name="header" >#{lbl['label.attachment']}</f:facet>

                                          <rich:dataTable value="#{li.files}" var="file" id="LicenceDatatable1"

                                                          style="width:100%;border: 0px;">

                                              <rich:column style="width:20%;  border: 0px;">

                                                  <h:commandLink actionListener="#{licenceIssuedMaster.downloadFile}"  value="#{lbl['label.download']}" id="LicenceDatacmdlkdwndld">

                                                      <f:param name="fileName" value="#{file.uploadedFileName}"/>

                                                      <f:param name="caseFileId" value="#{file.caseFileId}"/>

                                                  </h:commandLink>

                                              </rich:column>

                                          </rich:dataTable>

                                      </rich:column>

       

      licence.png

        • 1. Re: divide column in to two columns
          Michal Petrov Master

          Hi,

           

          I don't understand your issue, why can't you just add two columns to the table?

          • 2. Re: divide column in to two columns
            Asim Shaikh Novice

            I am trying to divide the attachment column into two sub  columns 1st attachment should Displays "Downloads" ans 2nd attachment should display "Ammended Download"

            • 3. Re: divide column in to two columns
              Michal Petrov Master

              You mean something like this: http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=dataTable&skin=blueSky ? Having two subheaders in the last column?

              1 of 1 people found this helpful
              • 4. Re: divide column in to two columns
                Asim Shaikh Novice

                Yes I wanted like this only But I am fetching Data from the same column in database I just want to show it in two different subcolumns

                • 5. Re: divide column in to two columns
                  Michal Petrov Master

                  Well if you know for sure there will be two files then simply use li.files.get(0), li.files.get(1). Assuming li.files is a List.

                  • 6. Re: divide column in to two columns
                    Asim Shaikh Novice

                    I have created two columns and trying to show two columns but it gives me the following error .my attachments are either 1 or 2 not exactly two .can it be possible to show them by Id column of table (where AttachmentId=1 in first column and AttachmentId=2 in second column)

                    javax.el.ELException: /merc/outputjsf/licenceissueddata.xhtml @55,85 value="#{li.files.get(1)}": java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

                     

                    <rich:column style="width:15%;" id="LicenceDataclm3">

                                                        <f:facet name="header" >#{lbl['label.attachment']}</f:facet>

                                                        <rich:dataTable value="#{li.files.get(1)}" var="file" id="LicenceDatatable1"

                                                                        style="width:100%;border: 0px;">

                                                            <rich:column style="width:20%;  border: 0px;">

                                                                <h:commandLink actionListener="#{licenceIssuedMaster.downloadFile}"  value="#{lbl['label.download']}" id="LicenceDatacmdlkdwndld">

                                                                    <f:param name="fileName" value="#{file.uploadedFileName}"/>

                                                                    <f:param name="caseFileId" value="#{file.caseFileId}"/>

                                                                </h:commandLink>

                                                            </rich:column>

                                                        </rich:dataTable>

                                                    </rich:column>

                                                  

                                                    <rich:column style="width:15%;" id="LicenceDataclm3_a">

                                                        <f:facet name="header" >#{lbl['label.attachment']}</f:facet>

                                                       <rich:dataTable value="#{li.files.get(0)}" var="file" id="LicenceDatatable1_a"

                                                                        style="width:100%;border: 0px;">

                                                            <rich:column style="width:20%;  border: 0px;">

                                                                <h:commandLink actionListener="#{licenceIssuedMaster.downloadFile}"  value="#{lbl['label.download']}" id="LicenceDatacmdlkdwndld_a">

                                                                    <f:param name="fileName" value="#{file.uploadedFileName}"/>

                                                                    <f:param name="caseFileId" value="#{file.caseFileId}"/>

                                                                </h:commandLink>

                                                            </rich:column>

                                                        </rich:dataTable>

                                                    </rich:column>

                    • 7. Re: divide column in to two columns
                      liumin hu Master

                      I dont think you can (need) put a datatable in another datatable. If I dont misunderstand, you just need put colspan for your column header attachement.

                       

                      Or you show us what you want by a picture.

                      • 8. Re: divide column in to two columns
                        Michal Petrov Master

                        java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

                        Well, that happens if there is only one item. You have to check the size of the list and then render accordingly - use the fn:length function (from xmlns:fn="http://java.sun.com/jsp/jstl/functions") to check the size of the list, list.size() won't work.

                        • 9. Re: divide column in to two columns
                          Asim Shaikh Novice

                          What to do If I wanted like if LicenceAttachId='1' show in first column

                          if LicenceAttachId='2'  show it in 2nd column or something like that  #{li.files.get(0)} is good but throwing errors

                          • 10. Re: divide column in to two columns
                            liumin hu Master

                            if you remove .get(0), what you get?

                            • 11. Re: divide column in to two columns
                              Asim Shaikh Novice

                              If I remove .get(o) I will get both the attachment perfectly. but I wanted to divide those attachment in two columns.

                              a ) If there is 1 attachment it should display in 1st column, 2nd column blank

                              b ) if 2 attachments should be displayed in both columns

                              <rich:dataTable value="#{li.files}" var="file" id="LicenceDatatable1">

                              • 12. Re: divide column in to two columns
                                liumin hu Master

                                you cant put a datatable in another datatable.

                                 

                                try this :

                                <rich:column>

                                     li.file[0].uploadedFileName

                                </rich:column>

                                <rich:column>

                                     li.file[1].uploadedFileName

                                </rich:column>

                                • 13. Re: Re: divide column in to two columns
                                  Michal Petrov Master

                                  a ) If there is 1 attachment it should display in 1st column, 2nd column blank

                                  b ) if 2 attachments should be displayed in both columns

                                  Well, why don't you put this into the page?

                                   

                                  <rich:column>
                                      <h:commandLink>
                                        <!-- li.files.get(0) -->
                                      </h:commandLink>
                                  </rich:column>
                                  <rich:column>
                                    <h:commandLink rendered="#{fn:length(li.files) == 2}"> <!-- if there are two items -->
                                        <!-- li.files.get(1) -->
                                      </h:commandLink>
                                  </rich:column>
                                  
                                  • 14. Re: divide column in to two columns
                                    Asim Shaikh Novice

                                    Thank you I will try with this .is their any need to declare fn :length seperately