Dan, Thank you for your answer. Actually my solution same as yours at last.
I modify defaultxxx function do not increase sequenceNumber to avoid side-effects. Database store next new sequence; And show sequenceNumber default value to user. 2015-07-29 13:58 GMT+08:00 Dan Haywood <d...@haywood-associates.co.uk>: > Apologies for not replying sooner on this one. > > I was going to reply that you shouldn't make any assumptions about how many > times the supporting methods are called, and in general that's true... they > should have no side-effects. After all, the user could hit cancel, in > which case (in your original implementation) the sequence number would > still have been incremented. > > In your particular use case, if the idea is that the system will > automatically generate a value for the sequence number but the user can > override, I would simply provide no default; then the logic to calculate > the next value should be in the action itself, eg: > > public MaintainRequest newMaintainRequest(String sequenceNumber, ...) { > if(sequenceNumber == null) { > SequenceGenerator seq = seqGens.findGenerator(); > Integer n=seq.getSequnceNumber(); > n++; > seq.setSequenceNumber(n); > sequenceNumber = ""+ seqGens.getSequenceNumber(); > } > ... > } > > That said , I had a quick look at the Wicket UI code, and it turns out to > be easy enough to change things to prevent the defaultXxx(...) being called > multiple times. So I've raised and committed a fix for ISIS-1179. > > Thanks > Dan > > > > > On 13 July 2015 at 02:20, Chuangyu <zhu.chuan...@gmail.com> wrote: > > > Hi, > > I create a defaultXXX method,in this method it fetchs a sequence number > > like below > > > > public Integer default0NewMaintainRequest(){ > > SequenceGenerator seq=seqGens.findGenerator(); > > Integer n=seq.getSequnceNumber(); > > n++; > > seq.setSequenceNumber(n); > > return n; > > } > > > > But it was called 2 times when invoke newMaintainRequest(Integer > > code.....), and sequence number was plus 2 every time. > > > > How can I avoid this behavior ? > > >