0

Say, I have a simple REST service, that get content of PDF file:

@Path("/pdf")
@Stateless
public class GroupSheetEJB {

. . .
  @GET
  @Path("examsheet/{groupId: \\d+}/{course: \\d+}/{semester: \\d+}/{subjectId: \\d+}")
  @Produces("application/pdf")
  public Response examSheet(@PathParam("groupId") int groupCode, @PathParam("course") int course,
    @PathParam("semester") int semester, @PathParam("subjectId") int subjectCode) {
    try {
      StudyGroup grp = groups.get(groupCode);
      Subject sub = subjects.get(subjectCode);
      ResponseBuilder response = Response.ok(getExamSheet(grp, sub, course, semester));
      return response.build();
    } catch (Exception e) {
      throw new NotFoundException(e.getMessage());
    }
  }
}

Is any way to easily get link for this REST service from <h:link> component? Now I use plain HTML tag:

<a target="examsheet" href="#{request.contextPath}/webresources/#{semesterSubjectMarksMB.examSheetLink}">REST link</a>

outcome parameter of with value /webresources/#{semesterSubjectMarksMB.examSheetLink} gets a disabled link.

Best regards.

gooamoko
  • 658
  • 12
  • 32
  • If the `a` tag is enough for you why use `h:link`? – Aritz Jul 01 '15 at 11:46
  • Enough, but I can re-render by various conditions. I just want to know - maybe there are some mechanisms to get paths for REST services. Is the hardcoded links good solution? – gooamoko Jul 02 '15 at 00:37
  • You can wrap the `a` tag in `ui:fragment` pieces in order to decide it to render or not. If you want to use a JSF specific tag, use a `h:outputLink` instead: http://stackoverflow.com/questions/6469298/difference-between-hlink-and-houtputlink – Aritz Jul 02 '15 at 06:21

0 Answers0