You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Wes Bramhall <We...@widen.com> on 2007/01/30 23:32:53 UTC

Should @Insert encode whitespace?

I have an app that displays a list of filenames to the user. I'm looping
over a list of File objects and displaying the names using an insert
component. Here's a barebones example:

<files jwcid="@For" source="ognl:files" value="ognl:loopFile">
	<filename jwcid="@Insert" value="ognl:loopFile.name" /><br />
</files>

It is possible to have filenames like "A  B", "A   B", and "A    B".
Sent to the insert component, they get rendered as "A  B", "A   B", and
"A    B" in the HTML source but end up displayed as "A B", "A B", and "A
B" on the screen. Setting the raw attribute to true doesn't change this
behavior. Would it be reasonable to encode consecutive spaces as &nbsp;?
Does anyone have a better idea?


For now I'll have to switch to the below code:

<files jwcid="@For" source="ognl:files" value="ognl:loopFile">
	<filename jwcid="@Insert" raw="ognl:true" value="ognl:safeName"
/><br />
</files>

public String getSafeName()
{
	return getLoopFile().getName().replace(" ", "&nbsp;");
}

Thanks,
-Wes

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


Re: Should @Insert encode whitespace?

Posted by andyhot <an...@di.uoa.gr>.
http://tapestry.apache.org/tapestry4.1/components/general/insert.html

Use the format parameter and provide it with a SpaceToNBSPFormat (that 
you also create)

Must leave raw to true.

Wes Bramhall wrote:
> I have an app that displays a list of filenames to the user. I'm looping
> over a list of File objects and displaying the names using an insert
> component. Here's a barebones example:
>
> <files jwcid="@For" source="ognl:files" value="ognl:loopFile">
> 	<filename jwcid="@Insert" value="ognl:loopFile.name" /><br />
> </files>
>
> It is possible to have filenames like "A  B", "A   B", and "A    B".
> Sent to the insert component, they get rendered as "A  B", "A   B", and
> "A    B" in the HTML source but end up displayed as "A B", "A B", and "A
> B" on the screen. Setting the raw attribute to true doesn't change this
> behavior. Would it be reasonable to encode consecutive spaces as &nbsp;?
> Does anyone have a better idea?
>
>
> For now I'll have to switch to the below code:
>
> <files jwcid="@For" source="ognl:files" value="ognl:loopFile">
> 	<filename jwcid="@Insert" raw="ognl:true" value="ognl:safeName"
> /><br />
> </files>
>
> public String getSafeName()
> {
> 	return getLoopFile().getName().replace(" ", "&nbsp;");
> }
>
> Thanks,
> -Wes
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>   


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


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


Re: Should @Insert encode whitespace?

Posted by Jesse Kuhnert <jk...@gmail.com>.
I don't remember which version this affected but I did fix a minor
whitespace issue in the template parser a few weeks ago. (I have no
idea, just know it's probably in >= 4.1.1 - it was related to i18n but
may be applicable to your situation )

On 1/30/07, Wes Bramhall <We...@widen.com> wrote:
> I have an app that displays a list of filenames to the user. I'm looping
> over a list of File objects and displaying the names using an insert
> component. Here's a barebones example:
>
> <files jwcid="@For" source="ognl:files" value="ognl:loopFile">
>         <filename jwcid="@Insert" value="ognl:loopFile.name" /><br />
> </files>
>
> It is possible to have filenames like "A  B", "A   B", and "A    B".
> Sent to the insert component, they get rendered as "A  B", "A   B", and
> "A    B" in the HTML source but end up displayed as "A B", "A B", and "A
> B" on the screen. Setting the raw attribute to true doesn't change this
> behavior. Would it be reasonable to encode consecutive spaces as &nbsp;?
> Does anyone have a better idea?
>
>
> For now I'll have to switch to the below code:
>
> <files jwcid="@For" source="ognl:files" value="ognl:loopFile">
>         <filename jwcid="@Insert" raw="ognl:true" value="ognl:safeName"
> /><br />
> </files>
>
> public String getSafeName()
> {
>         return getLoopFile().getName().replace(" ", "&nbsp;");
> }
>
> Thanks,
> -Wes
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

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