Messages to FeedBackPanel from AbstractAjaxBehavior onRequest

2011-10-05 Thread Tate Jones
Hi Group,

I have added a AbstractAjaxBehavior  to WebPage to recieve a 'post' request 
from JavaScript (.ajax post).  During the onRequest method an error could occur 
and I want to display this in the FeedbackPanel.  When I attempt to use the 
error(..) or info(..) method the following WARNING appears in the console.

WARNING: Component-targetted feedback message was left unrendered. This could 
be because you are missing a FeedbackPanel on the page.  Message: 
[FeedbackMessage message = to be display in feedback panel, reporter = 2, 
level = ERROR]

I already have a working Feedback panel on the page for a basic button submit 
method.

code fragment.

@AuthorizeInstantiation(Roles.ADMIN)
public class AdminPage extends WebPage {

private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(WebPage.class);

public AdminPage() {

add(new FeedbackPanel(feedback));


Form form = new Form(adminForm, new CompoundPropertyModel(tuneChip));
add(form);

form.add(new RequiredTextField(description));

   AbstractAjaxBehavior ajaxPostBehaviour = new AbstractAjaxBehavior() {
private static final long serialVersionUID = 1L;

@SuppressWarnings(unchecked)
public void onRequest() {
/**…..
some logic. The something goes wrong...
…..**/

error(Report Error Message);
}
};
add(ajaxPostBehaviour);

What is the best way to bind AbstractAjaxBehavior to the FeedbackPanel or 
should I used another approach?   As mentioned I am using AbstractAjaxBehavior 
to received a 'post' request.

eg.
 $.ajax({  +
url: ' + callBackURL + ', +
type: 'post', +
…etc..

Tate


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Messages to FeedBackPanel from AbstractAjaxBehavior onRequest

2011-10-05 Thread Tate Jones
Thanks Martin,

I am still learning so AbstractAjaxBehavior was my first choice.  No reason...

I have changed it to AbstractDefaultAjaxBehavior and added the following code 
to the respond method.

   target.addComponent(feedback);
   error(errorMessage);

However I still receiving the same WARNING message.

Layout

Page
- feedback
- form
- TextFields
- AbstractDefaultAjaxBehavior has been added here.

I must missing something very basic.

On 05/10/2011, at 5:57 PM, Martin Grigorov wrote:

 Hi,
 
 Why do you use AbstractAjaxBehavior instead of AbstractDefaultAjaxBehavior?
 
 AbstractDefaultAjaxBehavior passes you an instance of
 AjaxRequestTarget which you can use to add the feedback panel and show
 the feedback message. It writes a special XML back to the browser
 which wicket-ajax.js (e.g. wicketAjaxPost()) knows how to read and
 uses it to update the components.
 
 AbstractAjaxBehavior is a bit more general Ajax behavior with which
 you can write back to the response any kind of response (e.g. JSON).
 
 If you need both kind of responses then I suggest you to use
 AbstractDefaultAjaxBehavior to update components (target.add()) and
 target.appendJavaScript(someJSONP)
 
 On Wed, Oct 5, 2011 at 10:38 AM, Tate Jones t...@bluedog.com.au wrote:
 Hi Group,
 
 I have added a AbstractAjaxBehavior  to WebPage to recieve a 'post' request 
 from JavaScript (.ajax post).  During the onRequest method an error could 
 occur and I want to display this in the FeedbackPanel.  When I attempt to 
 use the error(..) or info(..) method the following WARNING appears in the 
 console.
 
 WARNING: Component-targetted feedback message was left unrendered. This 
 could be because you are missing a FeedbackPanel on the page.  Message: 
 [FeedbackMessage message = to be display in feedback panel, reporter = 2, 
 level = ERROR]
 
 I already have a working Feedback panel on the page for a basic button 
 submit method.
 
 code fragment.
 
 @AuthorizeInstantiation(Roles.ADMIN)
 public class AdminPage extends WebPage {
 
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(WebPage.class);
 
public AdminPage() {
 
add(new FeedbackPanel(feedback));
 
 
Form form = new Form(adminForm, new 
 CompoundPropertyModel(tuneChip));
add(form);
 
form.add(new RequiredTextField(description));
 
   AbstractAjaxBehavior ajaxPostBehaviour = new 
 AbstractAjaxBehavior() {
private static final long serialVersionUID = 1L;
 
@SuppressWarnings(unchecked)
public void onRequest() {
/**…..
some logic. The something goes wrong...
…..**/
 
error(Report Error Message);
}
};
add(ajaxPostBehaviour);
 
 What is the best way to bind AbstractAjaxBehavior to the FeedbackPanel or 
 should I used another approach?   As mentioned I am using 
 AbstractAjaxBehavior to received a 'post' request.
 
 eg.
 $.ajax({  +
url: ' + callBackURL + ', +
type: 'post', +
…etc..
 
 Tate
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
 
 -- 
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Messages to FeedBackPanel from AbstractAjaxBehavior onRequest

2011-10-05 Thread Tate Jones
No filters.

response() method did have this at the end.

IRequestTarget t = new StringRequestTarget(application/json, 
UTF-8, jsonAck);
getRequestCycle().setRequestTarget(t);

Once I removed this the warning message disappeared, however the feedback panel 
still didn't show the required message. 

On 05/10/2011, at 8:07 PM, Martin Grigorov wrote:

 On Wed, Oct 5, 2011 at 1:02 PM, Tate Jones t...@bluedog.com.au wrote:
 Thanks Martin,
 
 I am still learning so AbstractAjaxBehavior was my first choice.  No 
 reason...
 
 I have changed it to AbstractDefaultAjaxBehavior and added the following 
 code to the respond method.
 
   target.addComponent(feedback);
   error(errorMessage);
 
 However I still receiving the same WARNING message.
 This looks OK.
 I guess your FeedbackPanel has no explicit filter.
 
 Layout
 
 Page
- feedback
- form
- TextFields
- AbstractDefaultAjaxBehavior has been added here.
 
 I must missing something very basic.
 
 On 05/10/2011, at 5:57 PM, Martin Grigorov wrote:
 
 Hi,
 
 Why do you use AbstractAjaxBehavior instead of AbstractDefaultAjaxBehavior?
 
 AbstractDefaultAjaxBehavior passes you an instance of
 AjaxRequestTarget which you can use to add the feedback panel and show
 the feedback message. It writes a special XML back to the browser
 which wicket-ajax.js (e.g. wicketAjaxPost()) knows how to read and
 uses it to update the components.
 
 AbstractAjaxBehavior is a bit more general Ajax behavior with which
 you can write back to the response any kind of response (e.g. JSON).
 
 If you need both kind of responses then I suggest you to use
 AbstractDefaultAjaxBehavior to update components (target.add()) and
 target.appendJavaScript(someJSONP)
 
 On Wed, Oct 5, 2011 at 10:38 AM, Tate Jones t...@bluedog.com.au wrote:
 Hi Group,
 
 I have added a AbstractAjaxBehavior  to WebPage to recieve a 'post' 
 request from JavaScript (.ajax post).  During the onRequest method an 
 error could occur and I want to display this in the FeedbackPanel.  When I 
 attempt to use the error(..) or info(..) method the following WARNING 
 appears in the console.
 
 WARNING: Component-targetted feedback message was left unrendered. This 
 could be because you are missing a FeedbackPanel on the page.  Message: 
 [FeedbackMessage message = to be display in feedback panel, reporter = 
 2, level = ERROR]
 
 I already have a working Feedback panel on the page for a basic button 
 submit method.
 
 code fragment.
 
 @AuthorizeInstantiation(Roles.ADMIN)
 public class AdminPage extends WebPage {
 
private static final long serialVersionUID = 1L;
private static final Logger log = 
 LoggerFactory.getLogger(WebPage.class);
 
public AdminPage() {
 
add(new FeedbackPanel(feedback));
 
 
Form form = new Form(adminForm, new 
 CompoundPropertyModel(tuneChip));
add(form);
 
form.add(new RequiredTextField(description));
 
   AbstractAjaxBehavior ajaxPostBehaviour = new 
 AbstractAjaxBehavior() {
private static final long serialVersionUID = 1L;
 
@SuppressWarnings(unchecked)
public void onRequest() {
/**…..
some logic. The something goes wrong...
…..**/
 
error(Report Error Message);
}
};
add(ajaxPostBehaviour);
 
 What is the best way to bind AbstractAjaxBehavior to the FeedbackPanel or 
 should I used another approach?   As mentioned I am using 
 AbstractAjaxBehavior to received a 'post' request.
 
 eg.
 $.ajax({  +
url: ' + callBackURL + ', +
type: 'post', +
…etc..
 
 Tate
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
 
 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
 
 -- 
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: java.lang.IllegalStateException: STREAMED - Consuming JSON fails

2011-09-29 Thread Tate Jones
Cheers.

Changed the call to.

BufferedReader in = new BufferedReader(
new InputStreamReader(
hsr.getInputStream()));


On 28/09/2011, at 7:03 PM, Martin Grigorov wrote:

 This exception says Don't use the reader but use the input stream
 because something (maybe header) has been already read from the
 stream.
 
 On Wed, Sep 28, 2011 at 10:59 AM, Tate Jones t...@bluedog.com.au wrote:
 Hi Group,
 
 I am new to Wicket and I am attempting to read some JSON data posted from a 
 wicket page.
 
 The following exception occurs with Wicket 1.4.18 and Jetty 6.1.x when 
 attempting to read the servlet request - BufferedReader br = hsr.getReader().
 
 Sep 28, 2011 8:50:48 AM org.apache.wicket.RequestCycle logRuntimeException
 SEVERE: STREAMED
 java.lang.IllegalStateException: STREAMED
at org.mortbay.jetty.Request.getReader(Request.java:935)
at tunechipsapp.web.pages.LoginPage$2.onRequest(LoginPage.java:64)
at 
 org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:157)
at 
 org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at 
 org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1252)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1331)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1438)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:546)
at 
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at 
 org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at 
 com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
at 
 com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
 
 The code was source from 
 https://cwiki.apache.org/WICKET/how-to-handle-jqueryajax-json-request-.html
 
   AbstractAjaxBehavior ajaxSaveBehaviour = new AbstractAjaxBehavior() {
private static final long serialVersionUID = 1L;
 
@SuppressWarnings(unchecked)
public void onRequest() {
log.info(* onRequest *);
 
//get parameters
final RequestCycle requestCycle = RequestCycle.get();
 
WebRequest wr = (WebRequest) requestCycle.getRequest();
 
HttpServletRequest hsr = wr.getHttpServletRequest();
 
try {
BufferedReader br = hsr.getReader();   Exception
 
String jsonString = br.readLine();
if ((jsonString == null) || jsonString.isEmpty()) {
log.error( no json found);
} else {
log.info( json  is : + jsonString);
}
 
 
} catch (IOException ex) {
log.error(ex.toString());
}
 
// json string to retir to the jQuery onSuccess function
String data = {};
 
log.info(returning json : + data);
IRequestTarget t = new 
 StringRequestTarget(application/json, UTF-8, data);
getRequestCycle().setRequestTarget(t);
//requestCycle.setRequestTarget(new 
 StringRequestTarget(application/json, utf-8, data));
}
};
add(ajaxSaveBehaviour);
 
 I have read some posts about this in different forms (eg. pushing content), 
 but I haven't found a solution at this point.
 
 Cheers in advance
 Tate
 
 
 
 -- 
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



java.lang.IllegalStateException: STREAMED - Consuming JSON fails

2011-09-28 Thread Tate Jones
Hi Group,

I am new to Wicket and I am attempting to read some JSON data posted from a 
wicket page.

The following exception occurs with Wicket 1.4.18 and Jetty 6.1.x when 
attempting to read the servlet request - BufferedReader br = hsr.getReader().

Sep 28, 2011 8:50:48 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: STREAMED
java.lang.IllegalStateException: STREAMED
at org.mortbay.jetty.Request.getReader(Request.java:935)
at tunechipsapp.web.pages.LoginPage$2.onRequest(LoginPage.java:64)
at 
org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:157)
at 
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1252)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1331)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1438)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:546)
at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at 
com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
at 
com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)

The code was source from 
https://cwiki.apache.org/WICKET/how-to-handle-jqueryajax-json-request-.html

   AbstractAjaxBehavior ajaxSaveBehaviour = new AbstractAjaxBehavior() {
private static final long serialVersionUID = 1L;

@SuppressWarnings(unchecked)
public void onRequest() {
log.info(* onRequest *);

//get parameters
final RequestCycle requestCycle = RequestCycle.get();

WebRequest wr = (WebRequest) requestCycle.getRequest();

HttpServletRequest hsr = wr.getHttpServletRequest();

try {
BufferedReader br = hsr.getReader();   Exception

String jsonString = br.readLine();
if ((jsonString == null) || jsonString.isEmpty()) {
log.error( no json found);
} else {
log.info( json  is : + jsonString);
}


} catch (IOException ex) {
log.error(ex.toString());
}

// json string to retir to the jQuery onSuccess function
String data = {};

log.info(returning json : + data);
IRequestTarget t = new StringRequestTarget(application/json, 
UTF-8, data);
getRequestCycle().setRequestTarget(t);
//requestCycle.setRequestTarget(new 
StringRequestTarget(application/json, utf-8, data));
}
};
add(ajaxSaveBehaviour);
 
I have read some posts about this in different forms (eg. pushing content), but 
I haven't found a solution at this point.

Cheers in advance
Tate