markup not found on feedback panel (wicket 7.4)

2018-02-07 Thread Ernesto Reinaldo Barreiro
Hi,

On one application we are getting sporadic errors like

org.apache.wicket.markup.MarkupNotFoundException: Markup not found for
Component: [FencedFeedbackPanel [Component id = feedback]]
at org.apache.wicket.Component.internalRender(Component.java:2348)
at org.apache.wicket.Component.render(Component.java:2308)
at
org.apache.wicket.page.XmlPartialPageUpdate.writeComponent(XmlPartialPageUpdate.java:119)
at
org.apache.wicket.page.PartialPageUpdate.writeComponents(PartialPageUpdate.java:248)
at
org.apache.wicket.page.PartialPageUpdate.writeTo(PartialPageUpdate.java:161)
at
org.apache.wicket.ajax.AjaxRequestHandler.respond(AjaxRequestHandler.java:358)
at
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:97)
a

Error is not always produced. I have been checking JIRA and the only thing
I have found that looks similar is

https://issues.apache.org/jira/browse/WICKET-6027

But we are on 7.4 and it does not seem to be the same combination of
factors. If we could avoid going to newer versions and find why and
"workaround" that would be ideal.

Any hints? Related know issues?

-- 
Regards - Ernesto Reinaldo Barreiro


how to restrict the feedback message to display only one time for FormComponentPanel

2018-02-07 Thread extraquoo
our app has a phone number field like ###-###- x## on the page

 

We define a phone number class as FormComponentPanel in our app  like below 
public class PhoneFormComponent extends FormComponentPanel
{

private static final long serialVersionUID = 1L;

private TextField areaField;
private TextField threeField;
private TextField fourField;
private TextField extField;
private String area;
private String three;
private String four;
private String ext;

public PhoneFormComponent(String id, IModel phone) {
super(id, phone);
init();

}

private void init() {
if (getModelObject() != null) {
if 
(StringUtils.isNotBlank(getModelObject().getNumber())) {
String phoneNumber = 
getModelObject().getNumber();
area = phoneNumber.substring(0, 3);
three = phoneNumber.substring(4, 7);
four = phoneNumber.substring(8, 12);
}
ext = getModelObject().getExtension();
}
add(areaField = new TextField("area",
new PropertyModel(this, "area")));
areaField.add(new PatternValidator("\\d{3}")).setLabel(
new StringResourceModel("Phone", areaField, 
null));
add(threeField = new TextField("three",
new PropertyModel(this, "three")));
threeField.add(new PatternValidator("\\d{3}")).setLabel(
new StringResourceModel("Phone", threeField, 
null));
add(fourField = new TextField("four",
new PropertyModel(this, "four")));
fourField.add(new PatternValidator("\\d{4}")).setLabel(
new StringResourceModel("Phone", fourField, 
null));
add(extField = new TextField("ext", new 
PropertyModel(
this, "ext")));
extField.add(new PatternValidator("\\d{0,6}")).setLabel(
new StringResourceModel("Extension", extField, 
null));
areaField.add(new INullAcceptingValidator() {

/** Default serial id */
private static final long serialVersionUID = 1L;

@Override
public void validate(IValidatable validatable) {
if 
(StringUtils.isNotBlank(areaField.getConvertedInput()) != StringUtils

.isNotBlank(threeField.getConvertedInput())
&& 
StringUtils.isNotBlank(threeField

.getConvertedInput()) != StringUtils

.isNotBlank(fourField.getConvertedInput())) {
PhoneFormComponent.this.error(new 
ValidationError()

.addMessageKey("Incomplete"));
}
}

});
}

@Override
protected void convertInput() {
// note that earlier versions did override updateModel, which 
looked
// somewhat better, but wasn't useful for when you want to do
// validations with either normal validators or form validators
PhoneNumberType phoneNumber = new PhoneNumberType();
if (StringUtils.isNotBlank(areaField.getConvertedInput())
&& 
StringUtils.isNotBlank(threeField.getConvertedInput())
&& 
StringUtils.isNotBlank(fourField.getConvertedInput())) {
StringBuffer phoneString = new StringBuffer();
phoneString.append(areaField.getConvertedInput());
phoneString.append("-");
phoneString.append(threeField.getConvertedInput());
phoneString.append("-");
phoneString.append(fourField.getConvertedInput());
phoneNumber.setNumber(phoneString.toString());
phoneNumber.setExtension(extField.getConvertedInput());
setConvertedInput(phoneNumber);
} else if (StringUtils.isNotBlank(areaField.getConvertedInput())
|| 
StringUtils.isNotBlank(threeField.getConvertedInput())
|| 
StringUtils.isNotBlank(fourField.getConvertedInput())) {