You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jabbar <aj...@gmail.com> on 2006/11/20 12:09:40 UTC

Dynamic pattern for number translator for TextField

Hello,

I have a component definition for a textfield as follows

   		<component id="highThreshold" type="TextField">
  			<binding name="value"
value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>

  			<binding name="translator"
value="translator:number,pattern=#0.0########,omitZero=false"/>

  		</component>

What I want to know is if it is possible to replace
<binding name="translator"
value="translator:number,pattern=#0.0########,omitZero=false"/>

with <binding name="translator"
value="translator:number,pattern=numberformat,omitZero=false"/>


Note I have replaced pattern=#0.0######## with pattern=numberformat

-- 
Thanks

 A Jabbar Azam

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


Re: Re: Dynamic pattern for number translator for TextField

Posted by Sam Gendler <sg...@ideasculptor.com>.
Yeah, that's what I meant.  I thnk there is a Pattern validator but
not a Pattern translator.  The class name is just 'Pattern'

--sam

On 12/6/06, Jabbar <aj...@gmail.com> wrote:
> Hello Sam,
>
> I've only got round to implemeting this today :( Too much to do ...
>
> I couldn't find PatternTranslator.
>
> However, I used the following
>
>  <bean name="alarmValueFormat"
> class="org.apache.tapestry.form.translator.NumberTranslator">
>   <set name="pattern" value="alarmNumberPattern"/>
>   </bean>
>
>   <component id="highThreshold" type="TextField">
>   <binding name="value"
> value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>
>
> <binding name="translator" value="bean:alarmValueFormat"/>
>  <binding name="displayName" value="literal:High Threshold"/>
>
>  <binding name="disabled"
> value="(!currentChannelSetup.meterAlarmSetup.highFlowAlarmEnabled||channelDisabled)"/>
>                 </component>
> Where alarmNumberPattern is a getting (getAlarmNumberPattern) in my page class.
>
>
> On 21/11/06, Jabbar <aj...@gmail.com> wrote:
> > Thanks for that information I'll check out later.
> >
> > On 21/11/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> > > Without testing it, I'm not entirely sure if you can use ognl in that
> > > context, but you can definitely replace "value='translator:...'" with
> > > "value='bean:...'" and then populate the bean with an OGNL expression
> > > for the pattern property.  Without referring to example code to ensure
> > > I've got the syntax exactly correct, you can do something this:
> > >
> > > <bean id="numTrans"
> > > class="org.apache.tapestry.form.translator.PatternTranslator">
> > >    <binding name="pattern" value="ognl:numberFormat"/>
> > > </bean>
> > >
> > > I think the documentation on the tap website for translators and
> > > validators provides some examples along these lines.  Either that, or
> > > it is in in the pdf book. You can take a look at the javadocs for the
> > > various translators in order to determine what parameters you can set.
> > >
> > > --sam
> > >
> > > On 11/20/06, Jabbar <aj...@gmail.com> wrote:
> > > > Hello,
> > > >
> > > > I have a component definition for a textfield as follows
> > > >
> > > >                 <component id="highThreshold" type="TextField">
> > > >                         <binding name="value"
> > > > value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>
> > > >
> > > >                         <binding name="translator"
> > > > value="translator:number,pattern=#0.0########,omitZero=false"/>
> > > >
> > > >                 </component>
> > > >
> > > > What I want to know is if it is possible to replace
> > > > <binding name="translator"
> > > > value="translator:number,pattern=#0.0########,omitZero=false"/>
> > > >
> > > > with <binding name="translator"
> > > > value="translator:number,pattern=numberformat,omitZero=false"/>
> > > >
> > > >
> > > > Note I have replaced pattern=#0.0######## with pattern=numberformat
> > > >
> > > > --
> > > > Thanks
> > > >
> > > >  A Jabbar Azam
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> >
> > --
> > Thanks
> >
> >  A Jabbar Azam
> >
>
>
> --
> Thanks
>
>  A Jabbar Azam
>
> ---------------------------------------------------------------------
> 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: Dynamic pattern for number translator for TextField

Posted by Jabbar <aj...@gmail.com>.
Hello Sam,

I've only got round to implemeting this today :( Too much to do ...

I couldn't find PatternTranslator.

However, I used the following

 <bean name="alarmValueFormat"
class="org.apache.tapestry.form.translator.NumberTranslator">
  <set name="pattern" value="alarmNumberPattern"/>
  </bean>

  <component id="highThreshold" type="TextField">
  <binding name="value"
value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>

<binding name="translator" value="bean:alarmValueFormat"/>
 <binding name="displayName" value="literal:High Threshold"/>

 <binding name="disabled"
value="(!currentChannelSetup.meterAlarmSetup.highFlowAlarmEnabled||channelDisabled)"/>
  		</component>
Where alarmNumberPattern is a getting (getAlarmNumberPattern) in my page class.


On 21/11/06, Jabbar <aj...@gmail.com> wrote:
> Thanks for that information I'll check out later.
>
> On 21/11/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> > Without testing it, I'm not entirely sure if you can use ognl in that
> > context, but you can definitely replace "value='translator:...'" with
> > "value='bean:...'" and then populate the bean with an OGNL expression
> > for the pattern property.  Without referring to example code to ensure
> > I've got the syntax exactly correct, you can do something this:
> >
> > <bean id="numTrans"
> > class="org.apache.tapestry.form.translator.PatternTranslator">
> >    <binding name="pattern" value="ognl:numberFormat"/>
> > </bean>
> >
> > I think the documentation on the tap website for translators and
> > validators provides some examples along these lines.  Either that, or
> > it is in in the pdf book. You can take a look at the javadocs for the
> > various translators in order to determine what parameters you can set.
> >
> > --sam
> >
> > On 11/20/06, Jabbar <aj...@gmail.com> wrote:
> > > Hello,
> > >
> > > I have a component definition for a textfield as follows
> > >
> > >                 <component id="highThreshold" type="TextField">
> > >                         <binding name="value"
> > > value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>
> > >
> > >                         <binding name="translator"
> > > value="translator:number,pattern=#0.0########,omitZero=false"/>
> > >
> > >                 </component>
> > >
> > > What I want to know is if it is possible to replace
> > > <binding name="translator"
> > > value="translator:number,pattern=#0.0########,omitZero=false"/>
> > >
> > > with <binding name="translator"
> > > value="translator:number,pattern=numberformat,omitZero=false"/>
> > >
> > >
> > > Note I have replaced pattern=#0.0######## with pattern=numberformat
> > >
> > > --
> > > Thanks
> > >
> > >  A Jabbar Azam
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
> --
> Thanks
>
>  A Jabbar Azam
>


-- 
Thanks

 A Jabbar Azam

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


Re: Dynamic pattern for number translator for TextField

Posted by Jabbar <aj...@gmail.com>.
Thanks for that information I'll check out later.

On 21/11/06, Sam Gendler <sg...@ideasculptor.com> wrote:
> Without testing it, I'm not entirely sure if you can use ognl in that
> context, but you can definitely replace "value='translator:...'" with
> "value='bean:...'" and then populate the bean with an OGNL expression
> for the pattern property.  Without referring to example code to ensure
> I've got the syntax exactly correct, you can do something this:
>
> <bean id="numTrans"
> class="org.apache.tapestry.form.translator.PatternTranslator">
>    <binding name="pattern" value="ognl:numberFormat"/>
> </bean>
>
> I think the documentation on the tap website for translators and
> validators provides some examples along these lines.  Either that, or
> it is in in the pdf book. You can take a look at the javadocs for the
> various translators in order to determine what parameters you can set.
>
> --sam
>
> On 11/20/06, Jabbar <aj...@gmail.com> wrote:
> > Hello,
> >
> > I have a component definition for a textfield as follows
> >
> >                 <component id="highThreshold" type="TextField">
> >                         <binding name="value"
> > value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>
> >
> >                         <binding name="translator"
> > value="translator:number,pattern=#0.0########,omitZero=false"/>
> >
> >                 </component>
> >
> > What I want to know is if it is possible to replace
> > <binding name="translator"
> > value="translator:number,pattern=#0.0########,omitZero=false"/>
> >
> > with <binding name="translator"
> > value="translator:number,pattern=numberformat,omitZero=false"/>
> >
> >
> > Note I have replaced pattern=#0.0######## with pattern=numberformat
> >
> > --
> > Thanks
> >
> >  A Jabbar Azam
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
Thanks

 A Jabbar Azam

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


Re: Dynamic pattern for number translator for TextField

Posted by Sam Gendler <sg...@ideasculptor.com>.
Without testing it, I'm not entirely sure if you can use ognl in that
context, but you can definitely replace "value='translator:...'" with
"value='bean:...'" and then populate the bean with an OGNL expression
for the pattern property.  Without referring to example code to ensure
I've got the syntax exactly correct, you can do something this:

<bean id="numTrans"
class="org.apache.tapestry.form.translator.PatternTranslator">
    <binding name="pattern" value="ognl:numberFormat"/>
</bean>

I think the documentation on the tap website for translators and
validators provides some examples along these lines.  Either that, or
it is in in the pdf book. You can take a look at the javadocs for the
various translators in order to determine what parameters you can set.

--sam

On 11/20/06, Jabbar <aj...@gmail.com> wrote:
> Hello,
>
> I have a component definition for a textfield as follows
>
>                 <component id="highThreshold" type="TextField">
>                         <binding name="value"
> value="currentChannelSetup.meterAlarmSetup.highThresholdDouble"/>
>
>                         <binding name="translator"
> value="translator:number,pattern=#0.0########,omitZero=false"/>
>
>                 </component>
>
> What I want to know is if it is possible to replace
> <binding name="translator"
> value="translator:number,pattern=#0.0########,omitZero=false"/>
>
> with <binding name="translator"
> value="translator:number,pattern=numberformat,omitZero=false"/>
>
>
> Note I have replaced pattern=#0.0######## with pattern=numberformat
>
> --
> Thanks
>
>  A Jabbar Azam
>
> ---------------------------------------------------------------------
> 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