Pergunta

I'm experimenting with Wicket and event sourcing. I'm trying to log the user actions, so we can replay them or use them for testing or demoing purposes.

What would you recommend as strategy?

For example, I could define action classes and put them in the onsubmit etc. Or override all the 'action' components of wicket, e.g. the link, button, text field. Etc.

Any good advice?

Foi útil?

Solução 2

Use the request logger provided with Wicket out of the box since 1.2 (though its implementation has changed considerably over the years). This logs the request targets and responses in a (in 6.0, see wicket-extensions) JSON format for parsing. Note that depending on the number of users this can generate an unwieldy log.

Outras dicas

WARNING: This is NOT a solution to the problem. It might work for ajax only but I'm not sure about that either.

You could use an IComponentInstantiationListener to check for new Components beeing created and whether the're clickable or not. Then you could attach a Logging-Behavior. This way you could easily switch your logging on and off in one place and wouldn't have to subclass every Link-, Button, and Whatnot-class to do the logging.

Wicket itself doesn't provide hooks for something like this but depending on the other technologies you use you can do it in the persistency layer - e.g. with JPA's @PreRemove, @PreUpdate, @PrePersist. Another approach is Aspect Oriented Programming (AOP).

Considering every user action is a http request ajax or classic, you can log every request (every request has a component path) with some identifiers you need. In Wicket 1.4 you extend the request cycle, in 1.5+ add a request cycle listener.

See https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top