myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksei Valikov" <vali...@gmx.net>
Subject Re: Drilldown type app. without session bean?
Date Wed, 07 Dec 2005 00:36:40 GMT
Hi.

> Simon, Mike,
> 
> Thanks for the explanation.
> I was able to make it work by using below code:
> 
> FacesContext ctx = FacesContext.getCurrentInstance();
> ValueBinding binding = ctx.getApplication().createValueBinding("#{User}");
> binding.setValue(ctx, new User(id));
> 
> Trying to put the User bean in the request map was apparently the wrong 
> way of doing it:
> 
> ctx.getExternalContext().getRequestMap().put("#{User}", new User(id));
> 
> 
> The myfaces example use another method with t:updateActionListener. I will
> stay safe for now, and use above method. :)

I know many people will criticize my statement, but I think that EL in JSF
really needs method invocations. Several months ago I've added JavaScript
support to JSF (via Rhino) and my life has become MUCH easier.

That is, for the "drill-down" scenario you're describing, I'm using

<h:dataTable value="#{userManager.users}" var="user">
...
<h:commandButton value="Remove user"
action="#{[userManager.removeUser(user)]}"/>
...
</h:dataTable>

Where userManager has method like:

public String removeUser(User user) {...}

Square brackets in #{[...]} denote JavaScript expressions (all other
expressions are processed normally). JS scripts are compiled using Mozilla's
Rhino.

The danger is that JavaScript in EL allows moving controller logic back to
the JSPs (writing too much JavaScript in actions), which is undesirable. You
have to constrain yourself, but that's a tradeoff I can live with. Anyway,
#{[userManager.removeUser(user)]} is the most convenient solution from all
that I've seen.

Bye.
/lexi

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie

Mime
View raw message