Hello,
I want this String("------Original Message ----------")to only show up once in the subsequent Forward messages or Replys. I put in a for loop to ask to loop once but it is still showing up in subsequent forward messages. Can you tell me where I went wrong or what should be the proper way to do it?
Thanks,
Ngai
===========================================================
private Block createMsgBlock(MsgComposeBean msg, boolean isFwdReply) throws UControllerException {
try {
MessageComposeDBO composeDBO = new MessageComposeDBO();
List functions = composeDBO.getFunctions();
if (functions == null || functions.isEmpty()) {
throw new UControllerException("Could not retrieve the list of functions from the database.");
}
Block blockComposeMsg = new Block(BLOCK_MSG);
Input inputPrimRecipient = createPrimRecipientInput();
int count = 0;
FunctionBean bean = null;
String functionName = null;
Iterator iter = functions.iterator();
while (iter.hasNext()) {
bean = (FunctionBean) iter.next();
functionName = bean.getName();
inputPrimRecipient.addValidValue(functionName, functionName);
Block block = new Block(BLOCK + count);
Output out = new Output();
out.setName(OUT_RECIPIENT);
out.setAttribute(FUNCTION_NAME, functionName);
out.setAttribute(CHECKED, "");
//recipient for reply and forward.
block.add(out);
blockComposeMsg.add(block);
count++;
}
Input inputMsgType = createMsgTypeInput();
Input inputPriority = createMsgPriorityInput();
Output outSubject = new Output();
outSubject.setName(OUT_SUBJECT);
outSubject.setContent("");
Output outBody = new Output();
outBody.setName(OUT_BODY);
outBody.setContent(" ");
if (msg != null) {
//retrieve primaryRecipient
String primaryRecipient = getPRRecipients(msg.getIncidentId(), msg.getMsgId());
inputPrimRecipient.setDefaultValue(primaryRecipient);
// this is where you can add Sender and time
// sender sent mail
if (!isFwdReply) {
outSubject.setContent(msg.getSubject());
outBody.setContent(msg.getMsgBody());
} else {
outSubject.setContent(msg.getSubject());
StringBuffer prefix = new StringBuffer(OLD_MSG_PREFIX);
//This will only need to show up once attached to the original Message
//when user do as Rely or Forward message. Any subsequent forward
//or reply message should not carry "------Original Message ----------"
//in every newly looped in message as the rest will not be the
//original message any more.
String strOrgMsg = new String("------Original Message ----------");
int m;
for(m = 0; m < 1 ; m = m+1 ){
prefix.append(">").append(strOrgMsg).append('\n');
}
prefix.append(">").append("From :").append(msg.getSenderId()).append('\n');
prefix.append(">").append(" TO :").append(msg.getRecipient()).append('\n');
prefix.append(">").append("Subject :").append(msg.getSubject()).append('\n');
prefix.append(">").append("Date :").append(msg.getTimeSent()).append("\n\n\n");
int length = msg.getMsgBody().length();
String strBody = msg.getMsgBody();
if (!isNullOrEmpty(strBody)) {
prefix.append(">");
}
for (int i = 0; i < length; i++) {
char c = strBody.charAt(i);
if ('\n' == c) {
} else {
prefix.append(c);
}
}
outBody.setContent(prefix.toString());
}
if (!isFwdReply) {
inputMsgType.setDefaultValue(msg.getMsgType());
inputPriority.setDefaultValue(Integer.toString(msg.getPriority()));
}
}
blockComposeMsg.add(inputPrimRecipient);
blockComposeMsg.add(inputMsgType);
blockComposeMsg.add(inputPriority);
blockComposeMsg.add(outSubject);
blockComposeMsg.add(outBody);
return blockComposeMsg;
} catch (DBException e) {
throw new UControllerException("Exception: " + CLASS_NAME + ": error accessing database." + e, e);
}
}
I want this String("------Original Message ----------")to only show up once in the subsequent Forward messages or Replys. I put in a for loop to ask to loop once but it is still showing up in subsequent forward messages. Can you tell me where I went wrong or what should be the proper way to do it?
Thanks,
Ngai
===========================================================
private Block createMsgBlock(MsgComposeBean msg, boolean isFwdReply) throws UControllerException {
try {
MessageComposeDBO composeDBO = new MessageComposeDBO();
List functions = composeDBO.getFunctions();
if (functions == null || functions.isEmpty()) {
throw new UControllerException("Could not retrieve the list of functions from the database.");
}
Block blockComposeMsg = new Block(BLOCK_MSG);
Input inputPrimRecipient = createPrimRecipientInput();
int count = 0;
FunctionBean bean = null;
String functionName = null;
Iterator iter = functions.iterator();
while (iter.hasNext()) {
bean = (FunctionBean) iter.next();
functionName = bean.getName();
inputPrimRecipient.addValidValue(functionName, functionName);
Block block = new Block(BLOCK + count);
Output out = new Output();
out.setName(OUT_RECIPIENT);
out.setAttribute(FUNCTION_NAME, functionName);
out.setAttribute(CHECKED, "");
//recipient for reply and forward.
block.add(out);
blockComposeMsg.add(block);
count++;
}
Input inputMsgType = createMsgTypeInput();
Input inputPriority = createMsgPriorityInput();
Output outSubject = new Output();
outSubject.setName(OUT_SUBJECT);
outSubject.setContent("");
Output outBody = new Output();
outBody.setName(OUT_BODY);
outBody.setContent(" ");
if (msg != null) {
//retrieve primaryRecipient
String primaryRecipient = getPRRecipients(msg.getIncidentId(), msg.getMsgId());
inputPrimRecipient.setDefaultValue(primaryRecipient);
// this is where you can add Sender and time
// sender sent mail
if (!isFwdReply) {
outSubject.setContent(msg.getSubject());
outBody.setContent(msg.getMsgBody());
} else {
outSubject.setContent(msg.getSubject());
StringBuffer prefix = new StringBuffer(OLD_MSG_PREFIX);
//This will only need to show up once attached to the original Message
//when user do as Rely or Forward message. Any subsequent forward
//or reply message should not carry "------Original Message ----------"
//in every newly looped in message as the rest will not be the
//original message any more.
String strOrgMsg = new String("------Original Message ----------");
int m;
for(m = 0; m < 1 ; m = m+1 ){
prefix.append(">").append(strOrgMsg).append('\n');
}
prefix.append(">").append("From :").append(msg.getSenderId()).append('\n');
prefix.append(">").append(" TO :").append(msg.getRecipient()).append('\n');
prefix.append(">").append("Subject :").append(msg.getSubject()).append('\n');
prefix.append(">").append("Date :").append(msg.getTimeSent()).append("\n\n\n");
int length = msg.getMsgBody().length();
String strBody = msg.getMsgBody();
if (!isNullOrEmpty(strBody)) {
prefix.append(">");
}
for (int i = 0; i < length; i++) {
char c = strBody.charAt(i);
if ('\n' == c) {
} else {
prefix.append(c);
}
}
outBody.setContent(prefix.toString());
}
if (!isFwdReply) {
inputMsgType.setDefaultValue(msg.getMsgType());
inputPriority.setDefaultValue(Integer.toString(msg.getPriority()));
}
}
blockComposeMsg.add(inputPrimRecipient);
blockComposeMsg.add(inputMsgType);
blockComposeMsg.add(inputPriority);
blockComposeMsg.add(outSubject);
blockComposeMsg.add(outBody);
return blockComposeMsg;
} catch (DBException e) {
throw new UControllerException("Exception: " + CLASS_NAME + ": error accessing database." + e, e);
}
}