Désolé, je commence juste avec tous ces trucs EJB, JSF et JAX-RS et j'ai besoin de votre aide maintenant. J'ai créé une classe de ressources JAX-RS, qui fonctionne très bien et implémente @GET, @PUT, etc. Méthodes.Comment obtenir le chemin absolu de JAX-RS à partir de la page JSF?
Dans le même projet, j'ai maintenant créé une page JSF avec le BackBean correspondant. Ce Backbean devrait parler à l'interface REST. Pendant le test, j'ai codé en dur l'URI de l'interface REST dans le bean, mais bien sûr, j'aimerais obtenir l'URI par programmation. J'ai essayé avec une méthode @Produces et une injection, mais j'ai toujours une exception IllegalStateException. Je pense que cela a à voir avec les contextes, mais je n'ai pas la compréhension pour le résoudre.
Mon REST ressource:
@Path("task")
@ManagedBean
@RequestScoped
public class TaskResource {
@Context
private UriInfo context;
@Inject TaskLifecycle lc;
public TaskResource() {
}
@GET
@Path("{id}")
public Response getTask(@PathParam("id") String id) { ... etc.
Mon Backbean:
@ApplicationScoped
@LocalBean
@Named("tmmlWrapper")
public class TmmlTaskWrapperBean implements Serializable {
// Here another ManagedBean is injected, which works fine!
@Inject TaskLifecycle lc;
et enfin mon JSF Page:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Tasklist</title>
</h:head>
<h:body>
<h:form>
<h:outputLabel ><h3>Tasklist:</h3></h:outputLabel>
<h:dataTable value="#{tmmlWrapper.taskList}" var="tl">
<h:column>
<f:facet name="header">ID</f:facet>
#{tl.id}
</h:column> ... and so on ... etc.
Ma question: Comment mes BackBean obtenir l'URI la ressource REST (ex: "http: // exampledomain: 8080/as")? Toute aide est la bienvenue!
Cheers, Joern
Merci pour cela, ça marche! Je ne serais jamais allé dans cette direction! – Joern