1 Reply Latest reply on Sep 30, 2010 12:53 PM by John Franey

    polymorphism and clickable list

    John Franey Novice


      I have a solution to my issue.  I don't know if its the right one in seam lore.  If you practice a different technique, can you share?

      Say I run a vehicle rental and so database has the following jpa entities (pseudo code in use):

      abstract Vehicle {

      Car extends Vehicle
      Truck extends Vehicle

      I have a /vehicleList.xhtml which presents a clickable list, like in the tutorial, except my intention is: when the user clicks on a vehicle, the /car.xhtml or /truck.xhtml edit screen appears, not /vehicle.xhtml.

      The problem I'm trying to solve, is what to put on for the value of the s:link tag's action parameter?

      My solution is

      <s:link ... action="#{vehicleHome.editConcrete}/>"

      editConcreate is a method on my VehicleHome that would return either /truck.xhtml or /car.xhtml (based on return of getInstance.getClass(), for example).

      It works, I'm happy.  Feels sloppy.