You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Rodney Schneider <rl...@arcalink.com> on 2002/02/19 23:59:47 UTC

String comparison

Hi,

I know this has probably been asked a million times, but I can't seem to
find a straight answer in the docs or mailing list archives.  I am having
trouble getting String comparison working in my Velocity templates.
Here is some sample code I have for generating a select box with the
correct option selected:

-------------------------
#set ($selected = $author.AuthorType)
#if (!$selected)
  #set ($selected = "S")
#end

<select name="author_type">
  <option value="S"#if ($selected.equals("S")) selected="1"#end>Student</option>
  <option value="T"#if ($selected.equals("T")) selected="1"#end>Teacher</option>
  <option value="O"#if ($selected.equals("O")) selected="1"#end>Other</option>
</select>
--------------------------

I have also tried using:

#if ($selected == "S") selected="1"#end

But that doesn't seem to work either.  I have inserted html comments
into my template containing $selected, and it always prints out
correctly, but the code above still doesn't work.

Any help would be greatly appreciated.

Thanks,

-- Rodney

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: String comparison

Posted by Rodney Schneider <rl...@arcalink.com>.
On Wednesday 20 February 2002 10:01 am, you wrote:
> On 2/19/02 5:59 PM, "Rodney Schneider" <rl...@arcalink.com> wrote:
> > Hi,
> >
> > I know this has probably been asked a million times, but I can't seem to
> > find a straight answer in the docs or mailing list archives.  I am having
> > trouble getting String comparison working in my Velocity templates.
> > Here is some sample code I have for generating a select box with the
> > correct option selected:
> >
> > -------------------------
> > #set ($selected = $author.AuthorType)
> > #if (!$selected)
> > #set ($selected = "S")
> > #end
> >
> > <select name="author_type">
> > <option value="S"#if ($selected.equals("S"))
> > selected="1"#end>Student</option> <option value="T"#if
> > ($selected.equals("T")) selected="1"#end>Teacher</option> <option
> > value="O"#if ($selected.equals("O")) selected="1"#end>Other</option>
> > </select>
> > --------------------------
> >
> > I have also tried using:
> >
> > #if ($selected == "S") selected="1"#end
> >
> > But that doesn't seem to work either.  I have inserted html comments
> > into my template containing $selected, and it always prints out
> > correctly, but the code above still doesn't work.
> >
> > Any help would be greatly appreciated.
>
> What does $author.AuthorType return?

Sorry for the late reply... I've been busy on other stuff.  
$author.AuthorType should call author.getAuthorType() which returns a 
java.lang.String.

Thanks for your help,

-- Rodney

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


WYSIWYG editors

Posted by Shawn Church <sh...@boxity.com>.
I have always for the most part hand-coded html (including .vm and .wm
templates), but I am wondering if there is a quicker alternative.  I'm
through much of the Java coding for my most recent project, and I am just
beginning the trudge through the presentation layer.

Any opinions for or against a particular WYSIWYG editor is appreciated, and
of course it must at least tolerate the presence of embedded VTL.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Turning caching on

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 2/19/02 6:44 PM, "Darren Evenson" <DE...@safenetconsulting.com> wrote:

> Should I have anything to fear by turning caching on in production?

Fear itself?

> Are
> there any known issues where Velocity's behavior (output) is different based
> on whether caching is turned on or off?  I'm actually achieving acceptable
> performance without caching, but faster is always better.

It's faster.  I run cached.
 
> I'm using Velocity within my app to format email messages.  Unfortunately,
> for now, I'm locked into another templating language for my web pages :-)

Alas.  
 
> BTW, is there any way to take advantage of caching when the template comes
> from a String, rather than a file?

No, not yet.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The bytecodes are language independent. - Sam Ruby  


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Turning caching on

Posted by Darren Evenson <DE...@safenetconsulting.com>.
Should I have anything to fear by turning caching on in production?  Are
there any known issues where Velocity's behavior (output) is different based
on whether caching is turned on or off?  I'm actually achieving acceptable
performance without caching, but faster is always better.

I'm using Velocity within my app to format email messages.  Unfortunately,
for now, I'm locked into another templating language for my web pages :-)

BTW, is there any way to take advantage of caching when the template comes
from a String, rather than a file?

Thanks,
Darren A. Evenson

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: String comparison

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 2/19/02 5:59 PM, "Rodney Schneider" <rl...@arcalink.com> wrote:

> Hi,
> 
> I know this has probably been asked a million times, but I can't seem to
> find a straight answer in the docs or mailing list archives.  I am having
> trouble getting String comparison working in my Velocity templates.
> Here is some sample code I have for generating a select box with the
> correct option selected:
> 
> -------------------------
> #set ($selected = $author.AuthorType)
> #if (!$selected)
> #set ($selected = "S")
> #end
> 
> <select name="author_type">
> <option value="S"#if ($selected.equals("S")) selected="1"#end>Student</option>
> <option value="T"#if ($selected.equals("T")) selected="1"#end>Teacher</option>
> <option value="O"#if ($selected.equals("O")) selected="1"#end>Other</option>
> </select>
> --------------------------
> 
> I have also tried using:
> 
> #if ($selected == "S") selected="1"#end
> 
> But that doesn't seem to work either.  I have inserted html comments
> into my template containing $selected, and it always prints out
> correctly, but the code above still doesn't work.
> 
> Any help would be greatly appreciated.

What does $author.AuthorType return?

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>