Search code examples
spring-mvcspring-roo

How can I get Roo to produce a link that opens a create or edit page instead of text when it generates output for a page?


Currently in the list view for an entity, references to other entities are just output as the key value in plain text. Instead, I would like references to other entities to be output as hyperlinks.

I tried modifying the list.jspx but I couldn't figure out what I needed to add to the URL to make it open to the right controller. A pointer in the right direction would be helpful.


Solution

  • I find the roo tag libraries always point me in the right direction. Here is an example from src/main/webapp/WEB-INF/tags/form/fields/table.tagx that does something similar to what you are requesting:

     <spring:url value="${path}/${itemId}" var="update_form_url">
        <spring:param name="form" />
     </spring:url>
     <spring:url value="/resources/images/update.png" var="update_image_url" />
     <spring:message arguments="${typeName}" code="entity_update" var="update_label" htmlEscape="false" />
     <a href="${update_form_url}" alt="${fn:escapeXml(update_label)}" title="${fn:escapeXml(update_label)}">
        <img alt="${fn:escapeXml(update_label)}" class="image" src="${update_image_url}" title="${fn:escapeXml(update_label)}" />
     </a>
    

    Hopefully you can tweak this example to meet your needs.