Domanda

I have similar to scale to biological classification. I am looking for a tapestry component that can link them faster. However I am limitied to tapestry 5.2.6.

@Entity
public class Species implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NonVisual
    private Long Id;
    @Basic(optional = false)
    private String Name;   
    @ManyToOne   
    @NotFound(action = NotFoundAction.IGNORE)   
    private Kingdom kingdom; 
    //getter and setter frod data above
}

@Entity
public class Kingdom implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NonVisual
    private Long Id;
    @Basic(optional = false)
    private String Name; 
    @OneToMany
    private Collection<Species> speciesCollection;
    //getter and setter frod data above
}

We have entered in database 1000 records of Species and we want to link them. Only solution I know use select object ,which has complex code, inside the form that has a table. Which I think uses a GenericValueEncoder.

<td><t:label for="species"/></td><td><t:selectObject t:id="species" blankOption="never" list="speciesList" value="species" labelField="literal:name"/></td>

Sure selectobject works however its really slow comparing to palette or looping check-box (is not available in my version) for each entered species.

However main problem remains that I do not understand palette java code. Many variable have underlines, who know for what?

Since there are no comments anywhere, its hard to understand what does what, but what I assume I need to do change line 14.

to use GenericValueEncoder instead of EnumValueEncoder And GenericSelectModel instead of EnumSelectModel.

If any managed to implement palette with entity objects please tell me what to do?

È stato utile?

Soluzione

Here is an example of the Palette as we use it. Where I use Account, you can substitute it with your Species.

@Component(id = "accountsPalette", parameters = {
        "label=literal:My palette",
        "selected=selectedAccountsIds",
        "model=availableAccountIdsModel",
        "encoder=accountsEncoder"})
private Palette accountsPalette;

public SelectModel getAvailableAccountIdsModel() throws Exception {

    final List<OptionModel> options = new ArrayList<OptionModel>();

    for(Account account : availableAccounts) {

        options.add(new OptionModelImpl(account.getFullNameSingleType(), account.getId()));
    }

    return new AbstractSelectModel() {

        public List<OptionModel> getOptions() {
            return options;
        }

        public List<OptionGroupModel> getOptionGroups() {
            return null;
        }
    };
}

public ValueEncoder<Long> getAccountsEncoder(){
    return new ValueEncoder<Long>() {

        public String toClient(Long value) {
            return value.toString();
        }

        public Long toValue(String clientValue) {
            return Long.parseLong(clientValue);
        }
    };
}

public List<Long> getSelectedAccountsIds() {
    return selectedAccountIds;
}

public void setSelectedAccountsIds(List<Long> selectedAccountIds) throws Exception {
    ..... deal with the selected ids .....
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top