Hello everybody,

I'm really not sure about what I did and I really appreciate a feedback
from people who knows how persistent fields works.

If i'm not clear enough or anything about my issue, just let me know.

Cheers,
Charles.

2014-09-16 17:13 GMT+02:00 Charlouze <m...@charlouze.com>:

> As for now, I solved my problem using a new PersistentFieldStrategy and I
> want your opinion about it:
>
> public class MultiplePersistentFieldStrategy implements
> PersistentFieldStrategy {
>
>     private final Logger logger;
>
>     private final List<PersistentFieldStrategy> delegates;
>
>     public MultiplePersistentFieldStrategy(final Logger logger,
>             final List<PersistentFieldStrategy> delegates) {
>         this.logger = logger;
>         this.delegates = Lists.newArrayList(delegates);
>     }
>
>     @Override
>     public void postChange(final String pageName, final String
> componentId, final String fieldName,
>             final Object newValue) {
>         for (final PersistentFieldStrategy persistentFieldStrategy :
> delegates) {
>             try {
>                 persistentFieldStrategy.postChange(pageName, componentId,
> fieldName, newValue);
>                 return;
>             } catch (final RuntimeException e) {
>                 logger.debug("Error while using a
> PersistentFieldStrategy", e);
>             }
>         }
>         throw new IllegalArgumentException("Unable to find any suitable
> PersistentFieldStrategy");
>     }
>
>     @Override
>     public Collection<PersistentFieldChange> gatherFieldChanges(final
> String pageName) {
>         final List<PersistentFieldChange> persistentFieldChanges =
> Lists.newArrayList();
>         for (final PersistentFieldStrategy persistentFieldStrategy :
> delegates) {
>
> persistentFieldChanges.addAll(persistentFieldStrategy.gatherFieldChanges(pageName));
>         }
>         return persistentFieldChanges;
>     }
>
>     @Override
>     public void discardChanges(final String pageName) {
>         for (final PersistentFieldStrategy persistentFieldStrategy :
> delegates) {
>             persistentFieldStrategy.discardChanges(pageName);
>         }
>     }
> }
>
> Thanks again,
>
> Charles.
>
> 2014-09-16 16:29 GMT+02:00 Charlouze <m...@charlouze.com>:
>
>> Hello Tapestry users & devs,
>>
>> I have a component which does lots of ajax requests. Parameters setted at
>> the first render are not available upon ajax requests so I decided to
>> persist them in specific properties.
>> One of those parameter is a database entity (I use tapestry-jpa) so I
>> decided to use the the "entity" strategy so that my entity is reload and
>> managed on every request.
>> My problem is that when I use my component on a non persisted (yet)
>> entity, it crashes as it is a transient entity that cannot be found.
>>
>> Do you think of a better way than creating my own persistence strategy ?
>>
>> Thx in advance :D
>>
>
>

Reply via email to