How to create a multiple selection of tapestry baskets

Consider the following problem.

There is a page containing recycle bins. A basket is a component that contains a list of items such as fruits or cars or something else.

There are three baskets on the page: a basket for a car, a basket for fruits, and a basket. There are cars in the car basket, the fruit basket contains fruits, and the entire basket can contain both cars and fruits.

Initially, there are items only in baskets for cars and fruits. By clicking an item in these baskets, the item will be moved to the basket. By clicking an item in the entire basket, the element will be returned to the original basket.

In addition, fruit and car items are produced in different ways. For example, a car element may contain a different background than a fruit item. An element may also contain various information. For example, a car-element contains the maximum speed of the car and a fruit item containing the color of the fruit.

This rendering should also be preserved throughout the basket.

How would you make a tapestry page? I do not need a full implementation. I'm just interested in the principles of how this problem can be solved.

Also, for simplified implementation, can you give some estimate of how long it will take?

+3
source share
2 answers

. , / .

. ( " , " ), if .

<t:loop t:source="items" t:value="currentItem">
    <t:if t:test="currentCar">
       <span t:type="Car" t:car="currentCar" />
    </t:if>
     <t:if t:test="currentFruit">
       <span t:type="Fruit" t:fruit="currentFruit" />
    </t:if>
</t:loop>

A getCurrentCar() null, currentItem , getCurrentFruit() null, .

, ActionLinks . AJAX, Zone. , MultiZoneUpdate . ( , .)

, , , .

+2

:

<!-- render car basket -->
<t:loop t:source="carBasket" t:value="currentItem">
    <t:if t:test="currentCar">
       <span t:type="Car" t:car="currentCar" />
       <!-- TODO : eventlink for add to all basket -->
    </t:if>
</t:loop>

<!-- render fruit basket -->
<t:loop t:source="fruitBasket" t:value="currentItem">
     <t:if t:test="currentFruit">
       <span t:type="Fruit" t:fruit="currentFruit" />
       <!-- TODO : eventlink for add to all basket -->
    </t:if>
</t:loop>

<!-- render all basket -->
<t:loop t:source="allBasket" t:value="currentItem">
    <t:if t:test="currentCar">
       <span t:type="Car" t:car="currentCar" />
       <!-- TODO : eventlink for back to car basket -->
    </t:if>
     <t:if t:test="currentFruit">
       <span t:type="Fruit" t:fruit="currentFruit" />
       <!-- TODO : eventlink for back to fruit basket -->
    </t:if>
</t:loop>

-

@Property
private Item currentItem;

public Set<Item> getAllBasket(){
    return allBasket;
} 

public Set<Car> getCarBasket(){
    return carBasket;
} 

public Set<Fruit> getFruitBasket(){
    return fruitBasket;
}

public Fruit getCurrentFruit(){
   return currentItem instanceof Fruit ? (Fruit)item : null;
}

public Car getCurrentCar(){
    return curretItem instanceof Car ? (Car)item : null;
}
+1

Source: https://habr.com/ru/post/1763305/


All Articles