You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by karthi <ra...@snovabits.net> on 2012/05/28 14:48:19 UTC

img tag src value not get render on run time in lazy loading

Hi,

I am now creating an application where am having a page called content, in
that page now am displaying an image in the left side and a title,
description and some other info in the right side. It contains more than 40
items and displays 3 to 4 items in the screen at a time. 

The problem is it loads all the 40 items in the first shot, so planned to
try with lazy loading and tried with the link
http://ivorycity.com/blog/2011/04/19/jquery-lazy-loader-load-html-and-images-on-scroll/

First done a sample tapestry page with the code below:

<body>
layout/images/bmw_m1_hood.jpg <br/>
<div class="i-am-lazy"></div>
<div class="i-am-lazy"></div>
<div class="i-am-lazy"></div>
</body>

it works as expected it loads the first image normally and when i scroll
down it loads the consecutive images.

Next tried to implement the same thing in the coding like below:

<t:loop source="videoDatas" encoder="encoder" value="videoItem"
index="currIndex">
<table width="100%" cellpadding="2" cellspacing="0">
<tr class="list" style="background-color: ${alternateColour}">
<td> <div class="i-am-lazy"></div> </td>
<td width="100%">
<p class="link">
 ${videoItem.title} 
<br />
</p>
<p class="text">${videoItem.name}</p>
<br />
<div class="button_style">Info</div>
</td>
</tr>
</table>
</t:loop>

here the page loads successfully with title, name etc., but not with the
image, when i scrolled down the images are not get loaded, when i viewed the
page source and compared with the previous one (where gave the img src tag
value directly by src="layout/images/viper_1.jpg" so it loads successfully)
assigning  src="${videoItem.image}" it makes the problem at run time, it not
get the image value.

any one plz suggest me a solution?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by karthi <ra...@snovabits.net>.
I have first tried with this lazy load plugin for jquery
http://www.appelsiini.net/projects/lazyload, but there are some problems (It
works fine without iscroll component but with Iscroll it is not working in
iphone) with that that's why tried with some other lazy loading plugins, I
will try some other plugins or will try with your solution (if none works to
load the page faster with iscroll simply the solution would be pagination
link)

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713492.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by Lance Java <la...@googlemail.com>.
Gotcha ;)

Tapestry parses the TML file into a DOM object on the serverside and I'm not
100% sure what it does with XML (HTML) comments. It possibly discards them.

At any rate, I think you would be better to hide elements rather than
declaring them as comments and somehow uncommenting them at a later stage.

Perhaps this lazyload jquery image plugin might give you some inspiration
http://www.appelsiini.net/projects/lazyload

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713490.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by karthi <ra...@snovabits.net>.
Nabble swallowed my HTML... 

I have used the  correct comment in my coding, but for the above problem
only i just specified <!- 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713487.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by Lance Java <la...@googlemail.com>.
Nabble swallowed my HTML... I'll try again but will use [ ] instead of < >

The following is not valid XML / HTML:
[!- ${videoItem.image} --]

I guess Tapestry might be having troubles parsing the page. Comments should
be surrounded by [!-- and --].

If you want the image to load at a later stage, there are better ways to do
this in javascript.
1. Don't render the [img] in the initial page, and add the [img] to the DOM
at a later stage.
2. Render a hidden [img] but leave the "src" parameter empty and populate it
when you show the [img]. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713486.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by Lance Java <la...@googlemail.com>.
The following is not valid XML / HTML:
<!-&lt;img class=&quot;list_image&quot; src=&quot;${videoItem.image}&quot;
/>-->

I guess Tapestry might be having troubles parsing the page. Comments should
be surrounded by .

If you want the image to load at a later stage, there are better ways to do
this in javascript.
1. Don't render the   in the initial page, and add the   to the DOM at a
later stage.
2. Render a hidden   but leave the "src" parameter empty and populate it
when you show the  .



--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713485.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by karthi <ra...@snovabits.net>.
The following is the error I received,

[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
with uncaught exception: Input string '${videoItem.image}' is not valid; the
'$' character at position 1 should be followed by another '$' or a four
digit hex number (a unicode value).

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713483.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by karthi <ra...@snovabits.net>.
These urls are not coming from inside the webapp. I have an external url, hit
that & read the json response and parse the json to retrieve the title,
description, preview image url etc.,

My problem is, using that lazy loading to load the images used the code

<div class="i-am-lazy"><!-&lt;img class=&quot;list_image&quot;
src=&quot;${videoItem.image}&quot; />--></div>

that lazy load needs the comment line < ! -- to load the next items of
images when the user scroll down but the tapestry does not render the value
${videoItem.image} at run time.

This is my page source:

<div class="i-am-lazy"><!- -&lt;img class=&quot;list_image&quot;
src=&quot;${videoItem.image}&quot; />--></div></td><td colspan="1"
rowspan="1" width="100%"><p class="link">  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713482.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
Where do these URLs come from? Are they inside the webapp or not? If  
inside, make sure they start with / (absolute URLs).

On Mon, 28 May 2012 10:07:57 -0300, karthi <ra...@snovabits.net>  
wrote:

> Thank you for your reply, I used lazy loading only for images loading  
> since
> it contains a lot of images.
>
> I got the images url by
>
> <t:loop source="videoDatas" encoder="encoder" value="videoItem"
> index="currIndex"> *//Tapestry loop*
>
> public List<VideoItem> getVideoDatas() { *//Tapestry loop source*
> 		videoItems = null;
> 		if(isContent) {
> 			final VideoItemCollection collection = new
> VideoItemCollection(Constants.VIDEOS);
> 			if(collection.videoItems.size() > 0) {
> 				videoItems = collection.videoItems;
> 			}
> 		}
> 		return videoItems;
> 	}
>
> public VideoItemCollection(final String url) { *//loaded the values
> retrieved from json to pojo class*
>
> 		GetData data = new HttpGetData();
>
> 		try {
> 			final JSONObject object = new JSONObject(data.getContent(url));
> 			if(!object.isNull("videos")) {
> 				final JSONArray jsonArray = object.getJSONArray("videos");
> 				VideoItem item = new VideoItem();
> 				for(int index = 0; index < jsonArray.length(); index++) {
> 					item.setPosition(index);
> 				
> item.setImage(jsonArray.getJSONObject(index).optString("previewImage"));
> 					item.setName(jsonArray.getJSONObject(index).optString("name"));
> 					item.setTitle(jsonArray.getJSONObject(index).optString("title"));
> 					item.setType(jsonArray.getJSONObject(index).optString("type"));
> 					item.setUrl(jsonArray.getJSONObject(index).optString("url"));
> 					item.setId(jsonArray.getJSONObject(index).optString("id"));
> 					item.setSubUrl(jsonArray.getJSONObject(index).optString("suburl"));
> 					videoItems.add(item);
> 					item = new VideoItem();
> 				}
> 			}
> 		} catch(final Exception e) {
> 			logger.error(e);
> 		}
> 	}
>
> --
> View this message in context:  
> http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713441.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/

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


Re: img tag src value not get render on run time in lazy loading

Posted by karthi <ra...@snovabits.net>.
Thank you for your reply, I used lazy loading only for images loading since
it contains a lot of images.

I got the images url by 

<t:loop source="videoDatas" encoder="encoder" value="videoItem"
index="currIndex"> *//Tapestry loop*

public List<VideoItem> getVideoDatas() { *//Tapestry loop source*
		videoItems = null;
		if(isContent) {
			final VideoItemCollection collection = new
VideoItemCollection(Constants.VIDEOS);
			if(collection.videoItems.size() > 0) {
				videoItems = collection.videoItems;
			}
		}
		return videoItems;
	}

public VideoItemCollection(final String url) { *//loaded the values
retrieved from json to pojo class*

		GetData data = new HttpGetData();

		try {
			final JSONObject object = new JSONObject(data.getContent(url));
			if(!object.isNull("videos")) {
				final JSONArray jsonArray = object.getJSONArray("videos");
				VideoItem item = new VideoItem();
				for(int index = 0; index < jsonArray.length(); index++) {
					item.setPosition(index);
				
item.setImage(jsonArray.getJSONObject(index).optString("previewImage"));
					item.setName(jsonArray.getJSONObject(index).optString("name"));
					item.setTitle(jsonArray.getJSONObject(index).optString("title"));
					item.setType(jsonArray.getJSONObject(index).optString("type"));
					item.setUrl(jsonArray.getJSONObject(index).optString("url"));
					item.setId(jsonArray.getJSONObject(index).optString("id"));
					item.setSubUrl(jsonArray.getJSONObject(index).optString("suburl"));
					videoItems.add(item);
					item = new VideoItem();
				}
			}
		} catch(final Exception e) {
			logger.error(e);
		}
	}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/img-tag-src-value-not-get-render-on-run-time-in-lazy-loading-tp5713439p5713441.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: img tag src value not get render on run time in lazy loading

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 28 May 2012 09:48:19 -0300, karthi <ra...@snovabits.net>  
wrote:

> Hi,

Hi!

Do the images work without the lazy loading? How do you get the images  
URLs?

-- 
Thiago

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