You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Decebal Suiu <de...@asf.ro> on 2012/09/18 15:56:59 UTC

problem with IResourceListener

Hi

I want to make a open flash chart visible for an external web application
using a iframe. For this, I create a ChartWebPage and mount this page to
/chart.

In a few words, my problem is that the json data (string) returned by
OpenFlashChart (implements IResourceListener) are identical for both iframe
calls. Seems that wicket (1.5) returns same OpenFlashChart instance (see
hashCode from the console messages attached at end of the message) for both
iframe calls.

In other solution with json data served by a ChartDataResourceReference
mount on a /chart-data everything it's ok but are many code lines that
requires a change and I have a aggressive deadline. 

My code:

public class ChartWebPage extends WebPage {

	public ChartWebPage(PageParameters pageParameters) {
                // for debug (see console)
		System.out.println("ChartWebPage.ChartWebPage()");
		System.out.println(RequestCycle.get().getRequest().getUrl());

		String chartId = pageParameters.get("id").toString();
                String chartData = chartService.getJson(chartId);
                add(new OpenFlashChart("chart", Model.of(chartData)));
        }

...

}


public class OpenFlashChart extends GenericPanel<String> implements
IResourceListener {

	public OpenFlashChart(String id, IModel<String> jsonModel) {
		super(id, jsonModel);
       }

	@Override
	public void onResourceRequested() {
                // for debug (see console)
		System.out.println("OpenFlashChart.onResourceRequested()");
		System.out.println("requestUrl = " +
RequestCycle.get().getRequest().getUrl());
		System.out.println("... " + this.hashCode());
		IResource jsonResource = createJsonResource();
		IRequestHandler requestHandler = new ResourceRequestHandler(jsonResource,
null);
		requestHandler.respond(getRequestCycle());
	}

	private IResource createJsonResource() {
                // for debug (see console)
		System.out.println("OpenFlashChart.createJsonResource()");
		String jsonData = getModelObject();
		System.out.println("jsonData = " + jsonData);
		IResource jsonResource = new ByteArrayResource("text/plain",
jsonData.getBytes()) {
						
			@Override
			protected void setResponseHeaders(ResourceResponse data, Attributes
attributes) {
				data.disableCaching();
				super.setResponseHeaders(data, attributes);
			}
			
		};
		
		return jsonResource;
	}

....

}

In body section of my test.html file:

<iframe id="1"
src="http://localhost:8081/nextserver/app/chart?id=32836b83-27c5-43f7-a166-8ba38407d7dd"></iframe>
<iframe id="2"
src="http://localhost:8081/nextserver/app/chart?id=fb7e5efe-77c9-4494-9f99-9a577fef1687"></iframe>
               
In application console:

ChartWebPage.ChartWebPage()
chart?id=32836b83-27c5-43f7-a166-8ba38407d7dd
ChartWebPage.ChartWebPage()
chart?id=fb7e5efe-77c9-4494-9f99-9a577fef1687
OpenFlashChart.onResourceRequested()
requestUrl =
chart?0-IResourceListener-widget-renderer-chart&id=32836b83-27c5-43f7-a166-8ba38407d7dd
... 12027390
OpenFlashChart.createJsonResource()
jsonData = {"y_axis":{"min":4.3441,"colour":"000000","grid-colour":"333333",
...}
OpenFlashChart.onResourceRequested()
requestUrl =
chart?0-IResourceListener-widget-renderer-chart&id=fb7e5efe-77c9-4494-9f99-9a577fef1687
... 12027390
OpenFlashChart.createJsonResource()
jsonData = {"y_axis":{"min":4.3441,"colour":"000000","grid-colour":"333333",
...}

Best regards,
Decebal



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: problem with IResourceListener

Posted by dpmihai <dp...@yahoo.com>.
The strange thing is that only when the browser is just opened we see this
behavior. It is not deterministic and sometimes everything is ok from start.
Anyway, after a browser refresh, everything is ok. Also if we keep the
browser open, and new tabs with the iframes are opened, these are also ok.

So this problem seems to be related to iframe cache and some relation with
flash. We do not have any hard clue yet.

The only work-around we found was to do an auto-refresh  for the page that
contains iframes at first load, using javascript.

Although the url generated like "0-IResourceListener-widget-renderer-chart"
we saw that for IE is always the same starting with 0, and the iframes are
showing the wright content. In Firefox this number  gets incremented.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109p4652181.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: problem with IResourceListener

Posted by Decebal Suiu <de...@asf.ro>.
Thanks Martin

I understand this. But why urlFor(IResourceListener.INTERFACE, null);
returns "0-IResourceListener-widget-renderer-chart" in both situations (two
iframes in the same html file). The page version remains the same for both
calls. It's ok this behavior?

The problem appears only when I open for the first time the page with
iframes. After a refresh from browser (Firefox, Chrome) everything is ok.

Best regards,
Decebal



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109p4652137.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: problem with IResourceListener

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You make requests to the same page instance with the same components inside it.
I.e. 0-IResourceListener-widget-renderer-chart always uses the same
instance of 'chart' component.

On Wed, Sep 19, 2012 at 11:02 AM, Decebal Suiu <de...@asf.ro> wrote:
> I analyzed these lines (two iframes => two sessions):
>
> requestUrl =
> widget?0-IResourceListener-widget-renderer-chart&id=32836b83-27c5-43f7-a166-8ba38407d7dd
> objectHashCode = 12027390
>
> requestUrl =
> widget?0-IResourceListener-widget-renderer-chart&id=fb7e5efe-77c9-4494-9f99-9a577fef1687
> objectHashCode = 12027390
>
> The both request urls are the same without id parameter:
> widget?0-IResourceListener-widget-renderer-chart. My impression is that
> wicket doesn't have enough information to make a distinction between
> listener instances and it returns one of instances.
>
> Is my assumption correct?
>
> Best regards,
> Decebal
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109p4652134.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: problem with IResourceListener

Posted by Decebal Suiu <de...@asf.ro>.
I analyzed these lines (two iframes => two sessions):

requestUrl =
widget?0-IResourceListener-widget-renderer-chart&id=32836b83-27c5-43f7-a166-8ba38407d7dd 
objectHashCode = 12027390 

requestUrl =
widget?0-IResourceListener-widget-renderer-chart&id=fb7e5efe-77c9-4494-9f99-9a577fef1687 
objectHashCode = 12027390 

The both request urls are the same without id parameter:
widget?0-IResourceListener-widget-renderer-chart. My impression is that
wicket doesn't have enough information to make a distinction between
listener instances and it returns one of instances.

Is my assumption correct?

Best regards,
Decebal



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109p4652134.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: problem with IResourceListener

Posted by Decebal Suiu <de...@asf.ro>.
Additional information: if I put multiple OpenFlashChats in a
(Dashboard)Panel everything is ok. The problem appears if I use iframes.

Thanks,
Decebal



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/problem-with-IResourceListener-tp4652109p4652117.html
Sent from the Users forum mailing list archive at Nabble.com.

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