You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sommeralex <al...@gmail.com> on 2012/07/21 17:47:10 UTC
Test if production or test mode..
@Value("${tapestry.production-mode}")
@Property
private boolean productionMode;
this way sounds much easier than the crpytic form in the constructor:
public class MyService implements MyServiceInterface
{
public MyService(@Value("${tapestry.production-mode}") boolean
productionMode, ...)
{
if (productionMode) {
can someone explain me why app properties can not more easiliy requested?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658.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: Test if production or test mode..
Posted by Howard Lewis Ship <hl...@gmail.com>.
There's very little in Tapestry that could not be readily built in
Tapestry; it's not that what you are doing is impossible, it's just
that there hasn't been a sufficient need to streamline access to this
configuration symbol.
On Sat, Jul 21, 2012 at 8:47 AM, sommeralex <al...@gmail.com> wrote:
> @Value("${tapestry.production-mode}")
> @Property
> private boolean productionMode;
>
> this way sounds much easier than the crpytic form in the constructor:
>
> public class MyService implements MyServiceInterface
> {
> public MyService(@Value("${tapestry.production-mode}") boolean
> productionMode, ...)
> {
> if (productionMode) {
>
> can someone explain me why app properties can not more easiliy requested?
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658.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
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Test if production or test mode..
Posted by Christian Riedel <cr...@googlemail.com>.
…and if you worry about having too many annotations in the constructor, you can also omit the @Inject annoation for symbols in recent Tapestry versions (I think > 5.2).
@Symbol(SymbolConstants.PRODUCTION_MODE) boolean productionMode
Am 22.07.2012 um 15:34 schrieb Lance Java:
> You can use @Inject, @Value and @Symbol in tapestry services. @Property can
> only be used in pages and components, NOT services.
>
> The following should work in a service:
>
> @Inject @Symbol("tapestry.production-mode")
> private boolean productionMode;
>
> You could also do this:
>
> @Inject @Value("${tapestry.production-mode}")
> private boolean productionMode;
>
> I never use private field injection in my services (@Inject) as it makes it
> difficult to test but the option is there if you want it.
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714674.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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Test if production or test mode..
Posted by Lance Java <la...@googlemail.com>.
You can use @Inject, @Value and @Symbol in tapestry services. @Property can
only be used in pages and components, NOT services.
The following should work in a service:
@Inject @Symbol("tapestry.production-mode")
private boolean productionMode;
You could also do this:
@Inject @Value("${tapestry.production-mode}")
private boolean productionMode;
I never use private field injection in my services (@Inject) as it makes it
difficult to test but the option is there if you want it.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714674.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: Test if production or test mode..
Posted by Chris Mylonas <ch...@opencsta.org>.
Hi - I took the liberty in creating a JIRA for adding this example to the symbols page.
Handy example for someone getting into symbolic stuff (excuse my pun-tiness)
https://issues.apache.org/jira/browse/TAP5-1982
Here is the documentation I reckon could do with some more
http://tapestry.apache.org/symbols.html
For the quick and the dirty, it's a good example of injecting a symbol.
Dunno if it's jumpstart-worthy or stuff it into the archetype for more sample stuff without overwhelming a noob.
My 2c
Cheers
Chris
On 28/07/2012, at 7:02 PM, sommeralex wrote:
> thank you very much, it works!
>
> 2012/7/28 Taha Hafeez [via Tapestry] <
> ml-node+s1045711n5714850h92@n5.nabble.com>
>
>> With @Symbol you must use @Inject too
>>
>> @Proeprty
>> @Inject
>> @Symbol(SymbolConstants.PRODUCTION_MODE)
>> private boolean productionMode
>>
>> BTW you can also use :-
>>
>> <t:if test='symbol:tapestry.production-mode'>
>> ${symbol:tapestry.production-mode}
>> </t:if>
>>
>> regards
>> Taha
>>
>>
>> On Jul 28, 2012, at 2:19 PM, sommeralex wrote:
>>
>>> Thank you all for your answers.
>>>
>>> What I now did is just this in one of my pages:
>>>
>>> JAVA
>>>
>>> @Property
>>> @Symbol("tapestry.production-mode")
>>> private boolean productionMode;
>>>
>>> TML
>>>
>>> <t:if test="productionMode">
>>>
>>> productionMode!
>>>
>>> </t:if>
>>>
>>>
>>> My FrontendModule
>>>
>>> public static void
>> contributeApplicationDefaults(MappedConfiguration<String,
>>> String> configuration) {
>>>
>>> configuration.add("tapestry.production-mode", "true");
>>>
>>> }
>>>
>>> The String "productionMode!" is never printed. Using Tapestry 5.3.1.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html
>>
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=0>
>>> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=1>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=2>
>> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=3>
>>
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714850.html
>> To unsubscribe from Test if production or test mode.., click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5714658&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNDY1OHwxMDUzMzQxMzM4>
>> .
>> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714851.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: Test if production or test mode..
Posted by sommeralex <al...@gmail.com>.
thank you very much, it works!
2012/7/28 Taha Hafeez [via Tapestry] <
ml-node+s1045711n5714850h92@n5.nabble.com>
> With @Symbol you must use @Inject too
>
> @Proeprty
> @Inject
> @Symbol(SymbolConstants.PRODUCTION_MODE)
> private boolean productionMode
>
> BTW you can also use :-
>
> <t:if test='symbol:tapestry.production-mode'>
> ${symbol:tapestry.production-mode}
> </t:if>
>
> regards
> Taha
>
>
> On Jul 28, 2012, at 2:19 PM, sommeralex wrote:
>
> > Thank you all for your answers.
> >
> > What I now did is just this in one of my pages:
> >
> > JAVA
> >
> > @Property
> > @Symbol("tapestry.production-mode")
> > private boolean productionMode;
> >
> > TML
> >
> > <t:if test="productionMode">
> >
> > productionMode!
> >
> > </t:if>
> >
> >
> > My FrontendModule
> >
> > public static void
> contributeApplicationDefaults(MappedConfiguration<String,
> > String> configuration) {
> >
> > configuration.add("tapestry.production-mode", "true");
> >
> > }
> >
> > The String "productionMode!" is never printed. Using Tapestry 5.3.1.
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html
>
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=0>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=1>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=2>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5714850&i=3>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714850.html
> To unsubscribe from Test if production or test mode.., click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5714658&code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNDY1OHwxMDUzMzQxMzM4>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714851.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: Test if production or test mode..
Posted by Taha Siddiqi <ta...@gmail.com>.
With @Symbol you must use @Inject too
@Proeprty
@Inject
@Symbol(SymbolConstants.PRODUCTION_MODE)
private boolean productionMode
BTW you can also use :-
<t:if test='symbol:tapestry.production-mode'>
${symbol:tapestry.production-mode}
</t:if>
regards
Taha
On Jul 28, 2012, at 2:19 PM, sommeralex wrote:
> Thank you all for your answers.
>
> What I now did is just this in one of my pages:
>
> JAVA
>
> @Property
> @Symbol("tapestry.production-mode")
> private boolean productionMode;
>
> TML
>
> <t:if test="productionMode">
>
> productionMode!
>
> </t:if>
>
>
> My FrontendModule
>
> public static void contributeApplicationDefaults(MappedConfiguration<String,
> String> configuration) {
>
> configuration.add("tapestry.production-mode", "true");
>
> }
>
> The String "productionMode!" is never printed. Using Tapestry 5.3.1.
>
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Test if production or test mode..
Posted by sommeralex <al...@gmail.com>.
Thank you all for your answers.
What I now did is just this in one of my pages:
JAVA
@Property
@Symbol("tapestry.production-mode")
private boolean productionMode;
TML
<t:if test="productionMode">
productionMode!
</t:if>
My FrontendModule
public static void contributeApplicationDefaults(MappedConfiguration<String,
String> configuration) {
configuration.add("tapestry.production-mode", "true");
}
The String "productionMode!" is never printed. Using Tapestry 5.3.1.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.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: Test if production or test mode..
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sat, 21 Jul 2012 12:47:10 -0300, sommeralex
<al...@gmail.com> wrote:
> @Value("${tapestry.production-mode}")
> @Property
> private boolean productionMode;
You don't need @Property for injecting stuff. In addition, using @Symbol,
you don't need to use expansions:
@Inject
@Symbol(SymbolConstants.PRODUCTION_MODE) // or
@Symbol("tapestry.production-mode"), works the same.
private boolean productionMode;
> this way sounds much easier than the crpytic form in the constructor:
> public class MyService implements MyServiceInterface
> {
> public MyService(@Value("${tapestry.production-mode}") boolean
> productionMode, ...)
> {
> if (productionMode) {
>
> can someone explain me why app properties can not more easiliy requested?
Example of more easily requested way of doing that please. ;)
Do you really wanted an specific annotation just for injecting a single
symbol?
You could also inject the SymbolSource service and get symbol values from
it.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org