Class CardView

All Implemented Interfaces:
Serializable, EntityContainer, overit.geocall.clipboard.XClip, overit.geocall.marks.MethodExposer, overit.geocall.marks.NameExposer, AjaxableComponent, Badgeable, DAViewManager, DBViewManager, DraggableDroppable, Hideable, Identified, Tool, overit.geocall.ux.configurability.UIConfigurable, overit.geocall.ux.edm.ModelConfigurable
Direct Known Subclasses:
CardViewWfm, CVMaterials

@Component public class CardView extends ServerTableView
The class extends ServerTableView and implements the user interface objects that allows to show the records as cards. It is a responsive component which can adapts and reorganizes the cards accordingly to the available space of the page.
To use it, it is necessary to add a <![CDATA[]]> element directly as a child of CardView, as shown in the following example:

 <CardView>
      <![CDATA[
      <div>This is a format for a card {NAME}</div>
      ]]>
 </CardView>
as you can see, the content of CDATA is a format, and so it's possible to use variables and the other features exposed by the MapFormat class.
Alternatively it's possible to extend this class, implementing the getCardHtml() method, which will contain the logic that generates the html code necessary to render the contents of each card.
See Also:
GCApi:
component
  • Field Details

    • _reloadCard

      protected int _reloadCard
    • _cardWidth

      protected int _cardWidth
    • _cols

      protected int _cols
    • _cardFormat

      protected StringBuilder _cardFormat
  • Constructor Details

    • CardView

      public CardView()
  • Method Details

    • setROWS

      public void setROWS(String s)
      Empty method used to inhibit the use of ServerTableView's setRows(String s) method, use setCARDS(String)
      Overrides:
      setROWS in class ServerTableView
      Parameters:
      s - Empty method, use setCARDS(String)
    • setCARDS

      public void setCARDS(String s)
      Sets the number of cards to display for every page (the method activate the pagination mode of the CardView). If no value is specified for the extension attribute (ServerTableView.setEXTENSION(String)), the following pages will contain a number of cards equal to the value indicated with this method
      Parameters:
      s - The number of cards displayed for every page
    • setHEIGHT

      public void setHEIGHT(String s)
      Sets the height of the CardView.
      Overrides:
      setHEIGHT in class TableView
      Parameters:
      s - The height, expressed in pixels
    • setCARDWIDTH

      public void setCARDWIDTH(String s)
      Sets the width of every card. This is useful to constraint the card size; if not specified, every card will fit horizontally
      Parameters:
      s - The width of the single card, expressed in pixel
    • setCOLS

      public void setCOLS(String s)
      Sets number of (cards) columns for every row. If not specified the container try to insert as much card as possible in a single row.
      Parameters:
      s - The number of cards for every row
    • addChildText

      public void addChildText(String text)
      Description copied from class: UINode
      Empty method
      Overrides:
      addChildText in class UINode
      Parameters:
      text - Not used
    • buildSetupScript

      public void buildSetupScript(StringBuilder sb)
      Every component can add a script to the StringBuilder, script executed when the component is created The method add the script that manage the creation of the cards
      Overrides:
      buildSetupScript in class TableView
      Parameters:
      sb - The StringBuilder on which we want to add the script
    • buildDisplayScript

      public void buildDisplayScript(StringBuilder sb)
      Every component can add a script to the StringBuilder, script executed when the component is displayed The method add the script that manage the position of the scrollbar of the CardView
      Overrides:
      buildDisplayScript in class TableView
      Parameters:
      sb - The StringBuilder on which we want to add the script
    • getFrameHtml

      public org.apache.ecs.Element getFrameHtml(overit.geocall.ux.servlet.processor.Change c, EntitySet es)
      It defines the html part of the CardView that changes when an Ajax interaction occurs.
      Implements the AjaxableComponent interface.
      Specified by:
      getFrameHtml in interface AjaxableComponent
      Overrides:
      getFrameHtml in class ServerTableView
      Parameters:
      c - The Change object that defines the specific morphing type for the CardView
      es - The EntitySet to which the element belongs
      Returns:
      The html part of the CardView that changes when an Ajax interaction occurs
    • getCardView

      protected org.apache.ecs.Element getCardView(EntitySet es)
      Parameters:
      es - The EntitySet to which the element belongs
      Returns:
      the html structure containing all the cards
    • getCards

      protected List<org.apache.ecs.Element> getCards(EntitySet es, int from, int to)
      Parameters:
      es - The EntitySet to which the element belongs
      from - start page index
      to - end page index
      Returns:
      the list containing the html elements representing the cards contained within a page's range.
    • getCard

      protected org.apache.ecs.ConcreteElement getCard(EntitySet es, int index)
      Parameters:
      es - The EntitySet to which the element belongs
      index - card's position
      Returns:
      the html element of the card at the given index.
    • addJavascriptDDEvents

      protected void addJavascriptDDEvents(org.apache.ecs.html.Div item, int index)
    • addJavascriptClickEvents

      protected void addJavascriptClickEvents(org.apache.ecs.html.Div card, int index, StringBuilder cardClass)
    • addJavascriptMobileClickEvents

      protected void addJavascriptMobileClickEvents(int index, Ref<String> onclick, Ref<String> ontouchstart, Ref<String> ontouchend, Ref<String> ontouchmove, Ref<String> ontouchcancel)
    • addJavascriptDesktopClickEvents

      protected void addJavascriptDesktopClickEvents(int index, Ref<String> onclick, Ref<String> ondbclick, Ref<String> oncontextmenu, Ref<Boolean> roll)
    • getCardHtml

      protected org.apache.ecs.Element getCardHtml(EntitySet es, int index, HashGetter params)
      This method uses the html defined into CDATA child to render the content of the cards. If you haven't defined any CDATA child, or you want to generate a much more custom template, override this method with the logic that generates the html code necessary to render the content of a card
      Parameters:
      es - The EntitySet to which the element belongs
      index - The index of the card
      params - The map of the row rendered as a card
      Returns:
      The html code of a single card
    • changed

      public void changed(overit.geocall.ux.servlet.processor.Change c)
      Description copied from class: ServerTableView
      Defines the morphing of the table element that occurs when there is an Ajax interaction
      Implements the AjaxableComponent interface.
      Specified by:
      changed in interface AjaxableComponent
      Overrides:
      changed in class ServerTableView
      Parameters:
      c - The Change object that defines the specific morphing type for the table
    • getDefaultChange

      public overit.geocall.ux.servlet.processor.Change getDefaultChange()
      Description copied from class: TableView
      Defines the default Change object for the table.
      Implements the AjaxableComponent interface.
      Specified by:
      getDefaultChange in interface AjaxableComponent
      Overrides:
      getDefaultChange in class TableView
      Returns:
      The default Change object that defines the default morphing type of the table
    • changedCard

      protected void changedCard(int index)
    • clickOnControlMenu

      protected boolean clickOnControlMenu()
      Overrides:
      clickOnControlMenu in class TableView
    • userIsAllowedToEditTables

      protected boolean userIsAllowedToEditTables()
      Overrides:
      userIsAllowedToEditTables in class TableView
    • onControlMenu

      public boolean onControlMenu(UIMessage uim)
      Fired when the user click on the icon in the upper left corner of the CardView. Override the method to program the desired logic (like for example the expansion / contraction of all the cards)
      Overrides:
      onControlMenu in class TableView
      Parameters:
      uim - Not Used
      Returns:
      false