...
Code Block |
---|
add(new Link("changeAdLink") { {panel} public void onClick() { if (currentBanner.getClass() == Banner1.class) { TemplatePage.this.replace(currentBanner = new Banner2("ad")); } else { TemplatePage.this.replace(currentBanner = new Banner1("ad")); } } {panel} }); |
After the constructor change, the code with the same effect, looks like this:
Code Block |
---|
new Link(this, "changeAdLink") { {panel} public void onClick() { if (currentBanner.getClass() == Banner1.class) { new Banner2(TemplatePage.this, "ad"); } else { new Banner1(TemplatePage.this, "ad"); } } {panel} }; |
Alternatively, this could be rewritten like:
Code Block |
---|
new Link(this, "changeAdLink") { {panel} public void onClick() { if (currentBanner == banner1) { currentBanner = banner2; } else { currentBanner = banner1; } currentBanner.reAttach(); } {panel} }; |
Where we would hold references to banner1 and banner2 in the page after we created them:
...
Code Block |
---|
@Override public LibrarySession getSession() { {panel} return (LibrarySession)super.getSession(); {panel} } |
in a base class and then use
...
Form component level validation has been decoupled from FormComponent so that validators can be reused outside wicket. The new API can be found in <b>wicketwicket.
validation</b> validation
package, with the validator implementations in <b>wicketwicket.validation.
validator</b>validator
. From the point of view of validator development not much has changed if you extended the <b>AbstractValidator</b> AbstractValidator
; if you however implemented the IValidator
interface directly you will need to use the new API, namely error reporting via <b>ValidationError</b> ValidationError
instead of <b>FormComponentFormComponent.error(List,Map)
</b>. Errors with messages fully constructed inside the validator can still be reported using <b>FormComponentFormComponent.error(String)
</b>.