4 Replies Latest reply on Jan 24, 2011 3:12 PM by Don Esteban

    RichFaces 4 M5 rich:extendedDataTable - org.richfaces.model.selection.Selection

    Don Esteban Newbie

      Hi to everybody,

       

      I'm new to JSF and especially to RichFaces. My Environment is Eclips Helios, Mojarra 2.0.4 and Tomcat 6. I'm trying to anderstand the extendedDataTable. A very basic example is working fine. At the moment I try using the component to select a row and working on the backend with the selected row (Object).

       

      If I understand right, the selection should implement the org.richfaces.model.selection.Selection interface. That's what I found in the 3.3 documentation (http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/).

       

      <rich:extendedDataTable value="#{contactsBean.contacts}" var="contact"

                 selection="#{contactsBean.selections}" selectionMode="single">

        <rich:column>

          <h:outputText value="#{contact.id}" />

        </rich:column>

        <rich:column>

          <h:outputText value="#{contact.name}" />

        </rich:column>

      </rich:extendedDataTable>

      <h:commandButton value="selection to console" action="#{contactsBean.print}" />

       

      The Bean:

       

      ...

       

      @ManagedBean

      @SessionScoped

      public class ContactsBean implements Serializable {

       

                private final List<Contact> contacts;

                private List<Integer> selections;

       

       

                public ContactsBean() {


                          contacts = new ArrayList<Contact>();

                          contacts.add(new Contact(1, "James"));

                          contacts.add(new Contact(3, "John"));

                          contacts.add(new Contact(2, "Jack"));

               

                selections = new ArrayList<Integer>();

                          selections.add(2);


                }

       

                public List<Contact> getContacts() {

             return contacts;

                }

       

                public Collection<Integer> getSelections() {

                          System.out.println("get");

                          return selections;

                }

       

                public void setSelections(List<Integer> selections) {

                          System.out.println("set");

                          this.selections = selections;

                }

       

                public void print() {

                          if (selections.isEmpty()) {

                                    System.out.println("Empty");

                          } else {

                                    System.out.println(selections.get(0));

                          }

                }

      }

       

      Pressing the print button does show the selected row index. But I'm completely confused about what is going on. I would like to use the interface mentioned in the 3.3 docs but their is no such interface in the jars nor in the 4.0M5 docs. I could not find the corresponding docs for 4.0M5.

       

      I feel like I'm on the wrong road. Perhaps someone could explain the correct use of the selection feature or just point me to the docs.

       

      Thanks

      Don

        • 2. RichFaces 4 M5 rich:extendedDataTable - org.richfaces.model.selection.Selection
          Don Esteban Newbie

          Thanks a lot Ilya. Yes it is clear and you brought me on the road again. I would like to study the other examples, which came with the distribution.

           

          Could be something wrong with the pom.xml of the examples? I'm using maven now the first time and got errors. I followed the instructions in the readme, changed to the example  sub folder and executed the mvn clean package command.

           

          Do I do something obvious wrong (and have to read more maven docs) or is their realy something wrong with the pom.xml? Following the mvn output:

           

          mvn -X  clean package

          Apache Maven 3.0.2 (r1056850; 2011-01-08 21:58:10-0300)

          Java version: 1.6.0_22, vendor: Apple Inc.

          Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

          Default locale: de_DE, platform encoding: MacRoman

          OS name: "mac os x", version: "10.5.8", arch: "x86_64", family: "mac"

          [INFO] Error stacktraces are turned on.

          [DEBUG] Reading global settings from /Users/don/Documents/javaserver-faces-dev-2011/apache-maven-3.0.2/conf/settings.xml

          [DEBUG] Reading user settings from /Users/don/.m2/settings.xml

          [DEBUG] Using local repository at /Users/don/.m2/repository

          [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /Users/don/.m2/repository

          [INFO] Scanning for projects...

          [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repo1.maven.org/maven2

          Downloading: http://repo1.maven.org/maven2/org/richfaces/examples/richfaces-example-parent/4.0.0.20101226-M5/richfaces-example-parent-4.0.0.20101226-M5.pom

          [DEBUG] Reading resolution tracking file /Users/don/.m2/repository/org/richfaces/examples/richfaces-example-parent/4.0.0.20101226-M5/richfaces-example-parent-4.0.0.20101226-M5.pom.lastUpdated

          [DEBUG] Writing resolution tracking file /Users/don/.m2/repository/org/richfaces/examples/richfaces-example-parent/4.0.0.20101226-M5/richfaces-example-parent-4.0.0.20101226-M5.pom.lastUpdated

          [ERROR] The build could not read 1 project -> [Help 1]

          org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:

          [FATAL] Non-resolvable parent POM: Could not find artifact org.richfaces.examples:richfaces-example-parent:pom:4.0.0.20101226-M5 in central (http://repo1.maven.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 24, column 13

           

              at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:325)

              at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:632)

              at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:581)

              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:233)

              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)

              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

              at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

          [ERROR]  

          [ERROR]   The project org.richfaces.examples:core-demo:4.0.0.20101226-M5 (/Users/don/Documents/javaserver-faces-dev-2011/tmp/richfaces-4.0.0.20101226-M5/examples/core-demo/pom.xml) has 1 error

          [ERROR]     Non-resolvable parent POM: Could not find artifact org.richfaces.examples:richfaces-example-parent:pom:4.0.0.20101226-M5 in central (http://repo1.maven.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 24, column 13 -> [Help 2]

          org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact org.richfaces.examples:richfaces-example-parent:pom:4.0.0.20101226-M5 in central (http://repo1.maven.org/maven2)

              at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:183)

              at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:819)

              at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:670)

              at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:308)

              at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)

              at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:354)

              at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:305)

              at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:632)

              at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:581)

              at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:233)

              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

              at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)

              at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

              at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:597)

              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

          Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact org.richfaces.examples:richfaces-example-parent:pom:4.0.0.20101226-M5 in central (http://repo1.maven.org/maven2)

              at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:526)

              at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:214)

              at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:179)

              ... 21 more

          Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.richfaces.examples:richfaces-example-parent:pom:4.0.0.20101226-M5 in central (http://repo1.maven.org/maven2)

              at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:945)

              at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:940)

              at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:696)

              at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.flush(WagonRepositoryConnector.java:690)

              at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.get(WagonRepositoryConnector.java:435)

              at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:438)

              ... 23 more

          [ERROR]

          [ERROR]

          [ERROR] For more information about the errors and possible solutions, please read the following articles:

          [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

          [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

          • 4. RichFaces 4 M5 rich:extendedDataTable - org.richfaces.model.selection.Selection
            Don Esteban Newbie

            Thanks a lot Ilya, every is working fine now and I'm starting to understand thing better.