display authors
parent
846d94bb46
commit
d741bd019a
@ -0,0 +1,26 @@
|
|||||||
|
package ru.ulstu.user.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
import ru.ulstu.user.service.UserService;
|
||||||
|
|
||||||
|
import javax.faces.component.UIComponent;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.faces.convert.Converter;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserConverter implements Converter {
|
||||||
|
@Inject
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAsObject(FacesContext context, UIComponent component, String value) {
|
||||||
|
return value == null ? null : userService.findById(Integer.valueOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAsString(FacesContext context, UIComponent component, Object value) {
|
||||||
|
return ((User) value).getId().toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue