В отношении Struts 2 и бизнес-объектов и указанного там кода:
Я
cannot load the rp.randomCode
как это даетnull
. У меня 3_. Я могу загрузить (получить значение запросаparam
, если я использую старый код)Я не могу использовать
private fields
вRequestParam class
, потому что, если я хочу сделатьrp.randomCode
, поле случайного кода в классе RequestParam должно бытьpublic
. (хотя не хочу использоватьrp.getRandomCode()
). Это нехорошо, так как поля должны быть закрытыми.
новый код:
public class RequestParam{
private int userId;
private int groupType;
private int groupId;
private String groupTitle;
private String groupMemberIds;
private int randomCode;
private String message;
private int messageId; //internal class ues
//public getters and setters here
}
public class SendMessageOrStartChatAction extends BaseActoinSupport{
private RequestParam rp;
//public getters and setters here
@Override
protected void doExecute() throws IOException {
//check if it had random code in db, (msg already saved in db)
if(ChatDao.randomCodeExists(rp.randomCode)){
// ...........
}
}
}
старый код:
public class SendMessageOrStartChatAction extends BaseActoinSupport{
private static final long serialVersionUID = 1L;
private int userId;
private int groupType;
private int groupId;
private String groupTitle;
private String groupMemberIds;
private int randomCode;
private String message;
private int messageId; //internal class ues
@Override
protected void doExecute() throws IOException {
//check if it had random code in db, (msg already saved in db)
if(ChatDao.randomCodeExists(randomCode)){
messageId = ChatDao.getMessageIdThatMatchesRandomCode(randomCode);
write(messageId);
}else{
if(groupId <= 0){
//create group
groupId = ChatDao.createChatGroup(userId, groupTitle, groupType);
String[] memberIdsArray = groupMemberIds.split("==");
ChatDao.addUsersToGroup(groupId, memberIdsArray);
}
//save message
messageId = ChatDao.saveMessage(userId,groupId , message);
// queued: may be put this in last viewed messages here. may be.
write(messageId);
}
}
}
Как загрузить параметры, используя приведенный выше код?
put on hold as unclear what you're asking by Dave Newton, Kevin Panko, Mihai Maruseac, mdml, Sean Vieira 10 hours ago.
да, непонятно, вот почему я получил правильный ответ и положительный ответ на свой вопрос? - person Mab   schedule 19.11.2013