Showing posts with label Code sniplets. Show all posts
Showing posts with label Code sniplets. Show all posts

Jun 17, 2010

Blank lines in Error messages

For the blank line that is appearing for your action/field messages/errors, this is how you solve it:


  • Update the “.errorMessage” element in mpa.css Change to include the following:

margin-bottom:0px;

  • Change your JSP to hold each of the <s:actionErrors/> <s:actionMessages /> <s:fieldErrors/> in separate rows of your table.

<table cellspacing=“0”>
<tr>
<td>
<s:actionErrors />
</td>
</tr>
<tr>
<td>
<s:actionMessages />
</td>
</tr>
<tr>
<td>
<s:fieldErrors />
</td>
</tr>
</table>

  • Make sure that your table also has attribute “cellspacing=’0’”.

Jun 10, 2010

Struts, Annotations and Mime

To set a dynamic filename in annotated results.

In Action class:

private String date;

//Above the action handling the download:
@Result(name = "success", type= StreamResult.class,
params = {"contentType", "application/vnd.ms-excel",
"contentDisposition", "attachment; filename=report_$(date).xls"},
value = "reportFileStream"
)

//The usual getter/setter:
public String getDate(){
return date;
}

public void setDate(String date){
this.date = date;
}