I don't see how CDI helps. I tried 3 ways:

X denotes the value of the ID.

1) Pass id as view param using h:link:
<h:link value="edit" outcome="edit_thing">
  <f:param name="id" value="X"/>
</h:link>
and bind to pseudo-property named idToLoad in edit_thing.xhtml:
<f:metadata>
  <f:viewParam name="id" value="#{thingy.idToLoad}"/>
</f:metadata>

2) Pass id as view param using h:commandLink:
<h:commandLink value="edit" action="#{thingy.edit}">
  <f:param name="id" value="X"/>
</h:commandLink>
Action method named edit() gets id from FacesContext:
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id");
If that isn't inconvenient, what is? :)

3) Pass id as EL param using h:commandLink:
<h:commandLink value="edit" action="#{thingy.edit('X')}">
</h:commandLink>
myfaces complains:
java.lang.NoSuchMethodError:
javax.el.ELResolver.invoke(Ljavax/el/ELContext;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
My action method is:
public String edit(String id) { ... }
My web.xml has:
<context-param>
  <param-name>com.sun.faces.expressionFactory</param-name>
  <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
  <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
  <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
My pom.xml has:
<dependency>
   <groupId>javax.el</groupId>
   <artifactId>el-api</artifactId>
   <version>2.2</version>
   </dependency>
   <dependency>
   <groupId>org.glassfish.web</groupId>
   <artifactId>el-impl</artifactId>
   <version>2.2</version>
   </dependency>
I don't know why this fails.

What's the best style?

On Sat, Dec 4, 2010 at 8:31 AM, Gerhard <[email protected]> wrote:

> short addition:
>
> with myfaces codi also beans annotated with @ManagedBean are normal cdi
> beans (automatically).
>
> regards,
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
> 2010/12/4 Mark Struberg <[email protected]>
>
> > +1, with CDI you would be able to simply @Inject all your needed
> > parameters. In general I'd say that one should generally use CDI instead
> of
> > the JSF @ManagedBean mechanism.
> >
> > LieGrue,
> > strub
> >
> > --- On Sat, 12/4/10, Jakob Korherr <[email protected]> wrote:
> >
> > > From: Jakob Korherr <[email protected]>
> > > Subject: Re: myfaces popularity
> > > To: "MyFaces Discussion" <[email protected]>
> > > Date: Saturday, December 4, 2010, 3:45 PM
> > > ... or, you know, use CDI for your
> > > managed beans ;)
> > >
> > > Regards,
> > > Jakob
> > >
> > > 2010/12/4 Jakob Korherr <[email protected]>:
> > > > Hi,
> > > >
> > > > Sorry, I just skimmed your mail, but for your last
> > > point
> > > >
> > > >>Finally, what's the correct way to implement an
> > > editor action? The managed
> > > >>bean needs to be initialized before rendering it.
> > > So instead of invoking the
> > > >>no-arg constructor, I want something like:
> > > >>Foo(id)
> > > >>to be invoked.
> > > >
> > > > you can use a no-arg constructor and an init method
> > > annotated with
> > > > @PostConstruct. So something like this:
> > > >
> > > > @PostConstruct
> > > > private void init() { // init bean here }
> > > >
> > > > However, you can't pass arguments neither to the
> > > constructor nor to
> > > > this init method. You need to 1) get everything you
> > > need from the
> > > > context or 2) set them from outside via setter
> > > methods.
> > > >
> > > > Hope this helps.
> > > >
> > > > Regards,
> > > > Jakob
> > > >
> > > > 2010/12/3 ken keller <[email protected]>:
> > > >> My last startup is www.collectrium.com. We use
> > > AWS/py/django. This was my
> > > >> first non-Java app & I missed strong typing.
> > > django's template language is
> > > >> verbose & there's not much of a widget
> > > library. So I'm back to Java. AWS
> > > >> avoids setting up a data center (as co-founder of
> > > IGN.com, I don't miss
> > > >> managing 1,000 servers) but one still must manage
> > > the OS & scaling. So I'm
> > > >> trying appengine.
> > > >>
> > > >> jsf's attractions are validation, data binding,
> > > component model, component
> > > >> libraries. Too bad it doesn't include safe HTML
> > > (ala
> > > >>
> > http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html#SafeHtml)
> > > but
> > > >> it should be easy to wrap text components. Too bad
> > > the component library
> > > >> suppliers won't rally around a standard
> > > look-&-feel so one could mix
> > > >> components.
> > > >>
> > > >> I like gwt but it doesn't have validation &
> > > SEO is too hard. I might use gwt
> > > >> for editing functionality & a lightweight
> > > template language (which doesn't
> > > >> require a servlet container or mock for unit
> > > testing) like freemarker for
> > > >> browsing functionality.
> > > >>
> > > >> My current startup is a productivity tool in the
> > > cloud. I hope it will be
> > > >> used by many people of course.
> > > >>
> > > >> I'm using IntelliJ & appengine 1.3.8. From my
> > > web.xml:
> > > >>
> > > >>  <context-param>
> > > >>
> > >  <param-name>com.sun.faces.expressionFactory</param-name>
> > > >>
> > >  <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
> > > >>  </context-param>
> > > >>
> > > >> From my pom.xml:
> > > >>
> > > >>  <dependency>
> > > >>   <groupId>javax.el</groupId>
> > > >>   <artifactId>el-api</artifactId>
> > > >>   <version>2.2</version>
> > > >>   </dependency>
> > > >>   <dependency>
> > > >>
> > > <groupId>org.glassfish.web</groupId>
> > > >>   <artifactId>el-impl</artifactId>
> > > >>   <version>2.2</version>
> > > >>   </dependency>
> > > >>
> > > >> When I run the app, the log shows:
> > > >>
> > > >> INFO: Either you haven't specified the
> > > ExpressionFactory implementation, or
> > > >> an error occured while instantiating the
> > > implementation you've specified.
> > > >> However, attempting to load a known
> > > implementation.
> > > >>
> > > >> The app works but I wonder why.
> > > >>
> > > >> I'm having trouble w/ primefaces too.
> > > >>
> > > >> Finally, what's the correct way to implement an
> > > editor action? The managed
> > > >> bean needs to be initialized before rendering it.
> > > So instead of invoking the
> > > >> no-arg constructor, I want something like:
> > > >> Foo(id)
> > > >> to be invoked.
> > > >>
> > > >> On Fri, Dec 3, 2010 at 10:04 AM, Kito Mann <[email protected]>
> > > wrote:
> > > >>
> > > >>> Hello Ken,
> > > >>>
> > > >>> There's definitely a lot of activity in the
> > > JSF world, and it's used by a
> > > >>> lot of large and smaller companies (see
> > http://www.javaserverfaces.org/for
> > > >>> a list of sites built using JSF or Seam under
> > > "JSF in Production"). There
> > > >>> are a variety of industries, but it's quite
> > > popular in Finance (banks and
> > > >>> insurance companies).
> > > >>>
> > > >>> In terms of active development, you can just
> > > look at the recent releases to
> > > >>> see there's a lot going on.
> > > >>>
> > > >>> It's worthwhile also to point out that
> > > Trinidad is used as the foundation
> > > >>> for all of the Oracle Fusion applications.
> > > >>>
> > > >>> What sort of application is your startup
> > > intending to build with MyFaces?
> > > >>> ---
> > > >>> Kito D. Mann | twitter: kito99 | Author, JSF
> > > in Action
> > > >>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE
> > > training and consulting
> > > >>> http://www.JSFCentral.com - JavaServer
> > > Faces FAQ, news, and info |
> > > >>> twitter:
> > > >>> jsfcentral
> > > >>> +1 203-404-4848 x3
> > > >>>
> > > >>> Public JSF 2 Training this January in London:
> > > JSF 2 Update for JSF 1.x
> > > >>> users
> > > >>> (http://bit.ly/jsf2updatecourse<
> > > >>> http://skillsmatter.com/course/java-jee/jsf2-update-course>)
> > > >>> and JSF 2 in Action
> > > >>> (http://bit.ly/jsf2course<
> > > >>> http://skillsmatter.com/course/java-jee/jsf-and-ajax>
> > > >>> )
> > > >>>
> > > >>>
> > > >>>
> > > >>> On Fri, Dec 3, 2010 at 11:44 AM, ken keller
> > > <[email protected]>
> > > wrote:
> > > >>>
> > > >>> > 1Mpvs/day on which URL?
> > > >>> >
> > > >>> > mojarra looks inactive:
> > > >>> > http://java.net/projects/mojarra/lists
> > > >>> > The richfaces team seems to prefer
> > > mojarra to myfaces. Given the effort
> > > >>> > being devoted to richfaces &
> > > primefaces atop jsf2, one would think there
> > > >>> > would be much more activity on the
> > > lists.
> > > >>> >
> > > >>> > I've posted twice over the last few
> > > months about
> > > >>> >
> > > javax.faces.application.ViewExpiredException
> > > >>> > thrown on appengine but nobody replied.
> > > >>> >
> > > >>> > http://www.irian.at/myfaces_support
> > > >>> > costs $5,300/yr for basic
> > > support--$10,600 for advanced. My startup can't
> > > >>> > afford this--especially without trying it
> > > first--perhaps a paygo option.
> > > >>> >
> > > >>> > I haven't studied the source code to see
> > > if there's unit testing.
> > > >>> >
> > > >>> > As compelling as jsf2 is, I'm scared to
> > > bet my startup on it.
> > > >>> >
> > > >>> > On Fri, Dec 3, 2010 at 12:30 AM, Mark
> > > Struberg <[email protected]>
> > > >>> wrote:
> > > >>> >
> > > >>> > > Hi!
> > > >>> > >
> > > >>> > > With the pretty fast development on
> > > the spec side (last year 2.0, last
> > > >>> > week
> > > >>> > > 2.1 - thanks Ed!) there is a very
> > > steady development going on atm. Also
> > > >>> > > remember that EE6 is pretty fresh.
> > > >>> > >
> > > >>> > > So while there is currently not that
> > > much traffic on the us...@mf list
> > > >>> > > there is pretty much of it on the
> > > dev list atm.
> > > >>> > > The move from JSF-1.x to JSF-2.x is
> > > still to be done for most of the
> > > >>> > legacy
> > > >>> > > projects, but there are a few JFS-2
> > > projects already in production with
> > > >>> > lot
> > > >>> > > of success (we currently serve ~ 1
> > > mio page hits per day with
> > > >>> MyFaces-2,
> > > >>> > > OpenWebBeans, CODI, OpenJPA2 and our
> > > servers are pretty 'cold')
> > > >>> > >
> > > >>> > > LieGrue,
> > > >>> > > strub
> > > >>> > >
> > > >>> > > --- On Fri, 12/3/10, Matthias
> > > Wessendorf <[email protected]>
> > > wrote:
> > > >>> > >
> > > >>> > > > From: Matthias Wessendorf
> > > <[email protected]>
> > > >>> > > > Subject: Re: myfaces
> > > popularity
> > > >>> > > > To: "MyFaces Discussion" <[email protected]>
> > > >>> > > > Date: Friday, December 3, 2010,
> > > 7:44 AM
> > > >>> > > > On Fri, Dec 3, 2010 at 7:28 AM,
> > > ken
> > > >>> > > > keller <[email protected]>
> > > >>> > > > wrote:
> > > >>> > > > > This mailing list isn't
> > > very active. Most of the
> > > >>> > > > messages seem to be about
> > > >>> > > > > component libs like
> > > Trinidad.
> > > >>> > > > >
> > > >>> > > > > Is myfaces popular?
> > > >>> > > >
> > > >>> > > > yes it is.
> > > >>> > > >
> > > >>> > > > >
> > > >>> > > > > Wouldn't a searchable
> > > group be more convenient than a
> > > >>> > > > mailing list?
> > > >>> > > >
> > > >>> > > > the archives *are* searchable
> > > (e.g. markmail).
> > > >>> > > >
> > > >>> > > > >
> > > >>> > > >
> > > >>> > > >
> > > >>> > > >
> > > >>> > > > --
> > > >>> > > > Matthias Wessendorf
> > > >>> > > >
> > > >>> > > > blog: http://matthiaswessendorf.wordpress.com/
> > > >>> > > > sessions: http://www.slideshare.net/mwessendorf
> > > >>> > > > twitter: http://twitter.com/mwessendorf
> > > >>> > > >
> > > >>> > >
> > > >>> > >
> > > >>> > >
> > > >>> > >
> > > >>> >
> > > >>>
> > > >>
> > > >
> > > >
> > > >
> > > > --
> > > > Jakob Korherr
> > > >
> > > > blog: http://www.jakobk.com
> > > > twitter: http://twitter.com/jakobkorherr
> > > > work: http://www.irian.at
> > > >
> > >
> > >
> > >
> > > --
> > > Jakob Korherr
> > >
> > > blog: http://www.jakobk.com
> > > twitter: http://twitter.com/jakobkorherr
> > > work: http://www.irian.at
> > >
> >
> >
> >
> >
>

Reply via email to