Enum should be cast into an int anyway, not ToString-ed and Parse-d

On Tue, Jun 30, 2009 at 3:22 PM, bdaniel7 <bdani...@gmail.com> wrote:

>
> #set ($str = "123")
>
> <p>$Int32.Parse($str)</p>
>
> this, yes, it works.
>
> Anyway, for my Enum problem I created a small helper to use it for all
> conversions.
>
> Thanks for the heads up.
>
> On Jun 30, 3:18 pm, Ken Egozi <egoz...@gmail.com> wrote:
> > I'm no expert with NV syntax, but would
> > ...
> > $str = "123"
> > ...
> > <p>$Int32.Parse($str)</p>
> >
> > work for you?
> >
> >
> >
> > On Tue, Jun 30, 2009 at 3:14 PM, bdaniel7 <bdani...@gmail.com> wrote:
> >
> > > hm... the messages lead me to think that the type itself is not
> > > found...
> > > now i see that indeed i was using the wrong parameter for the helper.
> >
> > > at first i used $Int32.Parse(anEnumValue) and the method failed
> > > because it anEnumValue wasn't a string representation of a number.
> > > but now i'm testing $Int32.Parse("134") and it get displayed in the
> > > view as '$Int32.Parse("134")', instead of 134.
> >
> > > On Jun 30, 2:54 pm, Ken Egozi <egoz...@gmail.com> wrote:
> > > > if "Message: Method 'System.Int32.Parse'", then you might be using
> with
> > > the
> > > > wrong parameters,
> > > > could you please share your view code?
> >
> > > > On Tue, Jun 30, 2009 at 1:04 PM, bdaniel7 <bdani...@gmail.com>
> wrote:
> >
> > > > > Hello,
> > > > > I'm trying to use (for now) the static methods from $Int32, in NV
> > > > > views
> > > > > as presented here:
> >
> > > > >
> http://www.castleproject.org/monorail/documentation/trunk/viewengines.
> > > ..
> >
> > > > > However, i get an exception.
> > > > > i can still use $DateTime.
> >
> > > > > Is there something special that i must do to have access to the
> > > > > helper?
> >
> > > > > Thanks,
> > > > > Dan
> >
> > > > > The exception:
> > > > > MissingMethodException
> > > > > Message: Method 'System.Int32.Parse' not found.
> > > > > StackTrace:
> > > > > at System.RuntimeType.InvokeMember(String name, BindingFlags
> > > > > bindingFlags, Binder binder, Object target, Object[] providedArgs,
> > > > > ParameterModifier[] modifiers, CultureInfo culture, String[]
> > > > > namedParams)
> > > > > at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
> > > > > Binder binder, Object target, Object[] args)
> > > > > at
> > > > >
> Castle.MonoRail.Framework.Views.NVelocity.StaticAccessorHelper`1.Invoke
> > > > > (String method, Object[] args)
> > > > > at NVelocity.Runtime.Parser.Node.ASTMethod.Execute(Object o,
> > > > > IInternalContextAdapter context)
> > > > > at NVelocity.Runtime.Parser.Node.ASTReference.Execute(Object o,
> > > > > IInternalContextAdapter context)
> > > > > at NVelocity.Runtime.Parser.Node.ASTReference.Render
> > > > > (IInternalContextAdapter context, TextWriter writer)
> > > > > at NVelocity.Runtime.Parser.Node.SimpleNode.Render
> > > > > (IInternalContextAdapter context, TextWriter writer)
> > > > > at NVelocity.Template.Merge(IContext context, TextWriter writer)
> > > > > at
> > > > >
> Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.Process
> > > > > (String viewName, TextWriter output, IEngineContext context,
> > > > > IController controller, IControllerContext controllerContext)
> > > > > at
> Castle.MonoRail.Framework.Services.DefaultViewEngineManager.Process
> > > > > (String templateName, TextWriter output, IEngineContext context,
> > > > > IController controller, IControllerContext controllerContext)
> > > > > at Castle.MonoRail.Framework.Controller.ProcessView()
> > > > > at Castle.MonoRail.Framework.Controller.RunActionAndRenderView()
> >
> > > > --
> > > > Ken Egozi.
> > >http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.
> ..
> >
> > --
> > Ken Egozi.
> http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il
> >
>


-- 
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to