Discussion:
Feedback panel not displaying
SeldonCrisis
2018-10-29 14:40:12 UTC
Permalink
Hey guys,

I have an AjaxButton() that is being added to a WebMarkupContainer.

Within the onSubmit() of the button, I check to see whether there is already
an active session ID or not. If there is, I want to discontinue processing,
and display the feedback panel with an error message.

This ALMOST works, but the feedback panel won't display until after I click
the button TWICE.

So the FIRST time I click the button, it discontinues processing, the SECOND
time I click the button the feedback panel is added to the page.

Here's the button code:


And here's the code where I'm adding the message to the feedback panel:


So the message is added to the feedback panel in activeSessionExist() and
then the feedback panel is added to the target in the onSubmit() of the
button.

I wan't the feedback panel to be added to the page on the first click. Any
ideas as to whats going on?

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Francois Meillet
2018-10-29 14:58:02 UTC
Permalink
Hi,

Can’t see your code in your message.

François
Post by SeldonCrisis
Hey guys,
I have an AjaxButton() that is being added to a WebMarkupContainer.
Within the onSubmit() of the button, I check to see whether there is already
an active session ID or not. If there is, I want to discontinue processing,
and display the feedback panel with an error message.
This ALMOST works, but the feedback panel won't display until after I click
the button TWICE.
So the FIRST time I click the button, it discontinues processing, the SECOND
time I click the button the feedback panel is added to the page.
So the message is added to the feedback panel in activeSessionExist() and
then the feedback panel is added to the target in the onSubmit() of the
button.
I wan't the feedback panel to be added to the page on the first click. Any
ideas as to whats going on?
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
SeldonCrisis
2018-10-29 15:57:49 UTC
Permalink
Oh strange, probably because I put the code in < raw > tags. Thanks for the
heads up.

*OK, here's the button code:*
radioWmc1Step2.add(new AjaxButton("btnNewBegin") {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (activeSessionExist()){
target.add(feedback);
log.debug("Does the form have error:" + form.hasError());
return;
}
logUserAction(ocpAuthorization.getEmailAddress(), "602", "CP10", "OCP",
ocpAuthorization.getSecretTrackingNumber());
onPageSubmit(target);
}

@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
onSaveFormBtnError(target);
target.add(radioWmc1Step2);
target.appendJavaScript("trackingNumberMask();");
};
}

*And the code where I add to feedback panel*
private boolean activeSessionExist(){
OCPSession session = (OCPSession)WebSession.get();

if(session.getTrackingId() != null){
log.error("Active session found. Cannot have more than one OCP tracking
number open at a time.");
String error = "You have an active OCP Tracking Number open already. "
+ "This application only allows one active OCP Tracking Number. "
+ "Please use the \"Exit\" button to close that Tracking Number before
starting a new " + getTypeCode();

error(error);
return true;
}
return false;
}

Thanks again

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Francois Meillet
2018-10-29 17:03:47 UTC
Permalink
works great for me.

@Override
protected void onInitialize() {
super.onInitialize();

Form<Void> form = new Form<Void>("form");
add(form);

FeedbackPanel feedback = new FeedbackPanel("feedback");
feedback.setOutputMarkupId(true);
form.add(feedback);

form.add(new AjaxButton("AjaxButton") {

private static final long serialVersionUID = 1L;

@Override
public void onSubmit(AjaxRequestTarget target) {
if (activeSessionExist()) {
target.add(feedback);
log.debug("Does the form have error:" + getForm().hasError());
}
}

});
}

private boolean activeSessionExist() {
error("You have an active OCP");
return true;
}



What is printed at the log.debug("Does the form have error:" + form.hasError()); at the first click ?


François
Post by SeldonCrisis
Oh strange, probably because I put the code in < raw > tags. Thanks for the
heads up.
*OK, here's the button code:*
radioWmc1Step2.add(new AjaxButton("btnNewBegin") {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (activeSessionExist()){
target.add(feedback);
log.debug("Does the form have error:" + form.hasError());
return;
}
logUserAction(ocpAuthorization.getEmailAddress(), "602", "CP10", "OCP",
ocpAuthorization.getSecretTrackingNumber());
onPageSubmit(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
onSaveFormBtnError(target);
target.add(radioWmc1Step2);
target.appendJavaScript("trackingNumberMask();");
};
}
*And the code where I add to feedback panel*
private boolean activeSessionExist(){
OCPSession session = (OCPSession)WebSession.get();
if(session.getTrackingId() != null){
log.error("Active session found. Cannot have more than one OCP tracking
number open at a time.");
String error = "You have an active OCP Tracking Number open already. "
+ "This application only allows one active OCP Tracking Number. "
+ "Please use the \"Exit\" button to close that Tracking Number before
starting a new " + getTypeCode();
error(error);
return true;
}
return false;
}
Thanks again
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
Francois Meillet
2018-10-29 17:09:40 UTC
Permalink
also when you call error(), you call it on your component, not on the form.
you should call it like this :

private boolean activeSessionExist(Form<Void> form){
OCPSession session = (OCPSession)WebSession.get();

if(session.getTrackingId() != null){
log.error("Active session found. Cannot have more than one OCP tracking
number open at a time.");
String error = "You have an active OCP Tracking Number open already. "
+ "This application only allows one active OCP Tracking Number. "
+ "Please use the \"Exit\" button to close that Tracking Number before
starting a new " + getTypeCode();

form.error(error);
return true;
}
return false;
}


François
Post by SeldonCrisis
Oh strange, probably because I put the code in < raw > tags. Thanks for the
heads up.
*OK, here's the button code:*
radioWmc1Step2.add(new AjaxButton("btnNewBegin") {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
if (activeSessionExist()){
target.add(feedback);
log.debug("Does the form have error:" + form.hasError());
return;
}
logUserAction(ocpAuthorization.getEmailAddress(), "602", "CP10", "OCP",
ocpAuthorization.getSecretTrackingNumber());
onPageSubmit(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
onSaveFormBtnError(target);
target.add(radioWmc1Step2);
target.appendJavaScript("trackingNumberMask();");
};
}
*And the code where I add to feedback panel*
private boolean activeSessionExist(){
OCPSession session = (OCPSession)WebSession.get();
if(session.getTrackingId() != null){
log.error("Active session found. Cannot have more than one OCP tracking
number open at a time.");
String error = "You have an active OCP Tracking Number open already. "
+ "This application only allows one active OCP Tracking Number. "
+ "Please use the \"Exit\" button to close that Tracking Number before
starting a new " + getTypeCode();
error(error);
return true;
}
return false;
}
Thanks again
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
SeldonCrisis
2018-10-29 17:42:37 UTC
Permalink
Okay, I'm calling form.error() now instead. Unfortunately it didn't solve my
issue :(

On the first click this was printed:
000000af SystemOut O ERROR LandingPage_Cp10 Does the form have
error:true

So it recognizes that there is indeed an error, but it's not bring the
feedback panel along in the ajax response. Only after the second click the
ajax-response has all the correct feedback code.



--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Francois Meillet
2018-10-29 17:45:12 UTC
Permalink
Could you do a quickstart ?

François
Post by SeldonCrisis
Okay, I'm calling form.error() now instead. Unfortunately it didn't solve my
issue :(
000000af SystemOut O ERROR LandingPage_Cp10 Does the form have
error:true
So it recognizes that there is indeed an error, but it's not bring the
feedback panel along in the ajax response. Only after the second click the
ajax-response has all the correct feedback code.
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...