Java 如何在 displaytag 中创建链接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/788860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i create a link in displaytag?
提问by harshalb
I want to create edit , delete link in display tag with struts2. How can i do so ? If anybody knows please help me ....
我想用 struts2 创建编辑,删除显示标签中的链接。我该怎么做?如果有人知道请帮助我....
i am doing this.
我正在这样做。
<display:column property="id" title="ID" href="details.jsp" paramId="id" />
but the link is not going to details.jsp .It doesn't go anywhere . what can be the possible reason
但链接不会转到 details.jsp 。它不会去任何地方。可能的原因是什么
采纳答案by harshalb
It is done by the following code.
它是由以下代码完成的。
<display:column title="Edit">
<s:url id="updateUrl" action="marketing/update.action">
<s:param name="id" value="#attr.countrylist.id" />
</s:url>
<s:a href="%{updateUrl}" theme="ajax" targets="countrylist">Update</s:a>
</display:column>
Thanks for all the answers
感谢所有的答案
回答by Vincent Ramdhanie
You may have to be more specific in order to get better answers. Is the problem understanding struts2 or display tags? This tutorialexpains how to create links in display tags library.
为了得到更好的答案,您可能需要更具体。问题是理解struts2还是显示标签? 本教程解释了如何在显示标签库中创建链接。
If struts 2 is the problem then you could make you question more specific and we'll see what we can do.
如果 struts 2 是问题,那么您可以提出更具体的问题,我们将看看我们能做些什么。
回答by HaBaLeS
You can write your stuff within the tag like this:
你可以像这样在标签中写你的东西:
<display:table id="row" >
<display:column property="id" title="ID" paramId="id" >
<a href="details.jsp?${row.id}">Details</a>
</display:column>
</display:table>
回答by Thimmayya
You could also create a decorator for the table and have it generate the link. See example below on some other forum: http://sourceforge.net/forum/message.php?msg_id=4119964
您还可以为表创建一个装饰器并让它生成链接。请参阅以下其他论坛上的示例:http: //sourceforge.net/forum/message.php?msg_id= 4119964
回答by Edwin Pomayay
<display:table id="listaProgramas" name="programas" uid="tb"
pagesize="10" export="false" requestURI="/paginarProgramas.do"
class="ui-widget ui-widget-content">
<display:column title="Fecha de creación" property="fechaCreacionFormato" sortable="true"/>
<display:column title="Fecha de modificación" property="fechaModificacionFormato" sortable="true"/>
<display:column title="Empresa" property="nombreGrupoEmpresa"/>
<display:column title="Usuario" property="codUsuarioCreacion"/>
<display:column title="Estado" property="estadoPrograma.descripcion" />
<%if(pageContext.getAttribute("tb") != null && ((Programa)pageContext.getAttribute("tb")).getEstadoPrograma().getId().equals(Constantes.ID_ESTADO_PROGRAMA_PENDIENTE)){ %>
<display:column title="Modificar/Copiar" value="Modificar" url="/modificarCopiarPrograma.do" paramId="idPrograma" paramProperty="id" style="text-align:center;"/>
<%}%>
<%if(pageContext.getAttribute("tb") != null && ((Programa)pageContext.getAttribute("tb")).getEstadoPrograma().getId().equals(Constantes.ID_ESTADO_PROGRAMA_CERRADO)){ %>
<display:column title="Modificar/Copiar" value="Copiar" url="/modificarCopiarPrograma.do" paramId="idPrograma" paramProperty="id" style="text-align:center;"/>
<%}%>
<display:column title="Reporte Financiero" value="XLS" url="/generarExcel.do" paramId="idPrograma" paramProperty="id" style="text-align:center;">
<img src="image/excel.gif" alt="Descargar Excel"></img>
</display:column>
<display:column title="Reporte Financiero PDF" value="PDF" url="/downloadPDF.do" paramId="idPrograma" paramProperty="id" style="text-align:center;">
<img src="image/excel.gif" alt="Descargar Excel"></img>
</display:column>
</display:table>