خرید بک لینک

Vote count: 0

I would like to create a simple page that would diplay a user information

For instance if I reach ../profile.xhtml?id=10 I would like to get the page of the user with id=10.

Thus I would like to have an instance of this User in my profile.xhtml page.

I have tried :

<f:metadata>
    <f:viewParam id="id" name="id" value="#{shownUser}"/>
    <f:converter binding="#{userConverter}" />
</f:metadata>

with

@ManagedBean
@RequestScoped
public class UserConverter implements Converter {

@EJB
UserDAO userDao;

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
    User u = userDao.findFromId(value);
    return u;
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object obj) {
    User u = (User) obj;
    return u.getId().toString();
}

I expect to have my user as shownUser, unfortunatly the only answer I have is <f:converter> Parent not an instance of ValueHolder: javax.faces.component.UIViewRoot@10d8bc41 I deduce that doesn't work within but this contradicts with :

What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?

I succeed with (alongside a proper getAsObject(String id) function):

but I feel I miss the point of using the <f: /> tag and converters.

So my question is : Is it the common way to convert GET parameter ?

NB: I didn't used the converter properties of <f:viewParam> to be able to inject @EJB in the converter

asked 35 secs ago

برچسب: convert gettext a int,convert getdate,convert getdate to date,convert getdate to string,convert getdate to varchar,convert getdate to yyyymmdd,convert get to post,convert getdate to smalldatetime,convert getdate to string in ssis expression,convert getdate() to (dd,mm,yyyy) format in sql, نویسنده: استخدام کار تاريخ: يکشنبه 18 مهر 1395 ساعت: 5:29

صفحه بندی