Annotation Type SearchKey


  • @Retention(RUNTIME)
    @Target({FIELD,METHOD})
    public @interface SearchKey
    A search key property or reference is used by the user to search.

    Applies to properties and references.

    If the @Id property is @Hidden you can use SearchKey to indicate what property or reference will be used for searching.
    By default, OpenXava allows to the user to search objects (in references for example) by the @Id property, if the @Id property is hidden then the first property of the view is used. In some case you want to choose what properties will be use for searching. @SearchKey is for that. Example:

      @Id  @GeneratedValue(generator="system-uuid")  @Hidden 
      @GenericGenerator(name="system-uuid", strategy = "uuid")
      private String oid;
    
      @SearchKey
      @Column(length=4)  @DefaultValueCalculator(CurrentYearCalculator.class)
      private int year;
            
      @SearchKey
      @Column(length=6)
      private int number;
     
    In this case oid is a hidden id, and the user will be use year and number for searching the objects in references. The properties year and number are search keys.
    Author:
    Javier Paniza