【发布时间】:2015-02-19 05:40:04
【问题描述】:
我们正在 gsp 中显示文件。通过以下方式从后端提取文件:
查看
<table>
<tr>
<th>Attachment:
<td>
<g:each in="${lstAttachment}" var="nonOracleAttachmentItem">
<g:link id="${nonOracleAttachmentItem.Id}" action="nonOracleAttachment" params="[nonOracleAttachmentItemId: nonOracleAttachmentItem.Id,nonOracleAttachmentItemName: nonOracleAttachmentItem.Name]">${nonOracleAttachmentItem.Name}</g:link><br/>
</g:each>
</td>
</tr>
</table>
控制器
def show(){
def strAttachmentsName = null;
def boolAttachment = objChangeControl.Attachment__c
def strOrcAttachmentName = objChangeControl.Attachment_Name__c
if(strOrcAttachmentName !=null){
def lstOracleAttachment = salesforceService.getSObjectList(SFDC_ORG, "SELECT Id,Name from Attachment where ParentId='${idG}' AND Name='$strOrcAttachmentName'")
def lstAttachment = salesforceService.getSObjectList(SFDC_ORG, "SELECT Id,Name from Attachment where ParentId='${idG}' AND Name != '$strOrcAttachmentName'")
def oracleAttachmentId = lstOracleAttachment[0].Id
def oracleAttachmentName = lstOracleAttachment[0].Name
[oracleAttachmentId:oracleAttachmentId, oracleAttachmentName: oracleAttachmentName,lstAttachment:lstAttachment,grcInstance: objGRCChangeControl,updatedRAIInstance: objUpdatedRAI, strConfigurationOwner:strConfigurationOwner,strGRCStatusCustomSetting:strGRCStatusCustomSetting,sfUserName: session["${SFDC_ORG}UserName"],sfUserId:sfUserId]
}else{
def lstAttachment = salesforceService.getSObjectList(SFDC_ORG, "SELECT Id,Name from Attachment where ParentId='${idG}'")
[lstAttachment:lstAttachment,grcInstance: objGRCChangeControl,updatedRAIInstance: objUpdatedRAI, strConfigurationOwner:strConfigurationOwner,strGRCStatusCustomSetting:strGRCStatusCustomSetting,sfUserName: session["${SFDC_ORG}UserName"],sfUserId:sfUserId]
}
}
这一切都很好,除非表单中的字段验证失败并且我们需要保留所有字段值以及最初显示的文件。这是显示错误并呈现用户在验证错误之前输入的值的 catch 块(在按下“提交”按钮后调用的方法内)。我怎样才能渲染文件呢?
def submitGRCRecord(){
try{
......
}
catch (Exception e){
render(action:"show",model:[sfUserName: session["${SFDC_ORG}UserName"], sfUserId: session["${SFDC_ORG}UserId"],encodedId:encodedIdParam,grcInstance: getGRCRecord(),inputITGNumber:inputITGNumber,inputJustification:inputJustification,attmtChecked: 'true',lstAttachment:params['lstAttachment']])
}
【问题讨论】: