[Building Sakai] Very basic velocity question: parsing data from java to template in Sakai

Steve Swinsburg steve.swinsburg at gmail.com
Tue Nov 5 12:53:35 PST 2013


Lose the curly braces, you don't need them in this instance, you only need
them if the variable name was actually part of another sentence. Also, if
the variable isn't set, then Velocity outputs the variable name in its
entirety. You can disable that by printing it as:

$*!*passwordExpireMessage

and it will be blank.

And thats what you are getting (the var name being printed because the
contents are not set), so I would be checking that where you set the
variable in the Java class, is the correct spot.

So what I would end us with is:

<span class="pawword-expire-warning">
$passwordExpireMessage
</span>

Once you have it working, then internationalise with the resource loader
and the properties file. Don't introduce that complexity just yet ;)

cheers,

Steve




On Wed, Nov 6, 2013 at 2:57 AM, Matthew Jones <matthew at longsight.com> wrote:

> I'm not sure, it works for me. You're redeploying the webapp with the new
> war, and new source code from that java file, right? I'd make 100% that
> your variable names match up, in your span class it says
> pawword-expire-warning, making me think you might have had a typo.
>
> Though what you *really* want to do for something like this is put it in
> portal-impl/impl/src/bundle/sitenav.properties
>
> *pwd_expire_msg = Some message about expiration*
>
> And use the ResourceLoader, which for portal looks like it is
>
> ${rloader.pwd_expire_msg}
>
>
>
>
> On Tue, Nov 5, 2013 at 10:22 AM, David Wafula Wanyonyi <
> DavidWafula.Wanyonyi at wits.ac.za> wrote:
>
>>  Hi all,
>> Never used velocity before, so my first attempt is not going any where;
>> please point me where am getting it wrong:
>>
>> in
>> https://source.sakaiproject.org/svn/portal/tags/portal-base-2.9.2/portal-impl/impl/src/java/org/sakaiproject/portal/charon/SkinnableCharonPortal.java,
>>
>>
>>
>> there is  includeLogin(),  with lines:
>> ....
>>   rcontext.put("loginLogInOutUrl", logInOutUrl);
>>   rcontext.put("loginMessage", message);
>> .......
>>
>> so am adding something simple:
>>
>>  String pwdMessage = "Warning: Your password is expiring in 6 days";
>>   rcontext.put("passwordExpireMessage", pwdMessage);
>>
>>
>> I go to includeTabs.vm:
>>
>> <span class="pawword-expire-warning">
>> ${passwordExpireMessage}
>> </span>
>>
>> it prints '${passwordExpireMessage}' instead of actual message
>>
>>
>> if i try and replace this with say ${loginMessage}, just for testing, the
>> correct message is printed.
>>
>>
>>
>> The trick ?
>> Thanks.
>>
>>  This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorised signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary.
>>
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>
>
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to
> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
> "unsubscribe"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20131106/63e7e266/attachment.html 


More information about the sakai-dev mailing list