Envoie d'objet complexe via HTTPService
Bonjour,
Je cherche une solution générique pour envoyer un objet complexe (un objet contenant une liste d'objets) vers une action struts 2
voici l'objet à envoyer côté flex
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
public class Demand implements ValueObject, XMLElementOrderable
{
public var label:String;
public var localization:String;
public var reference:String;
public var project:String;
public var posts:ArrayCollection = new ArrayCollection();
public function Demand()
{
}
public function getElementOrder():Array
{
return ["id","contact","label","localization","reference","state","posts"];
}
} |
le problème ici est la manière de récupérer les objets posts (l'objet récupérer est de type XwoorList non par List<Post> comme déclarer dans l'action). y a-t-il une solution générique pour pouvoir les lire proprement côté java ou il faut faire une manipulation pour les convertir en une liste de string pour les envoyer en http service.
Voici le code de l'action
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
public class DemandAction extends AbstractAction {
/**
* ID
*/
private static final long serialVersionUID = 1L;
private DemandsManagerDelegate demandsManagerDelegate;
public DemandsManagerDelegate getDemandsManagerDelegate() {
return demandsManagerDelegate;
}
public void setDemandsManagerDelegate(DemandsManagerDelegate demandsManagerDelegate) {
this.demandsManagerDelegate = demandsManagerDelegate;
}
/**
* Logger
*/
private static final Log LOG = LogFactoryImpl.getLog(DemandAction.class);
/**
* {@link Demand}
*/
private Demand demand = new Demand();
public List<Post> getPosts() {
return demand.getPosts();
}
public void setPosts(List<Post> posts) {
demand.setPosts(posts);
}
/**
* Id
*
* @return the id
*/
public Integer getId() {
return demand.getId();
}
/**
* setId
*
* @param id
* the id to set
*/
public void setId(Integer id) {
this.setId(id);
}
/**
* localization
*
* @return the localization
*/
public String getLocalization() {
return demand.getLocalization();
}
/**
* setLocalisation
*
* @param localization
* the localization to set
*/
public void setLocalization(String localization) {
demand.setLocalization(localization);
}
/**
* reference
*
* @return the reference
*/
public String getReference() {
return demand.getReference();
}
/**
* setReference
*
* @param reference
* the reference to set
*/
public void setReference(String reference) {
demand.setReference(reference);
}
/**
* state
*
* @return the state
*/
public Integer getState() {
return demand.getState();
}
/**
* setState
*
* @param state
* the state to set
*/
public void setState(Integer state) {
demand.setState(state);
}
/**
* demandStartDate
*
* @return the demandStartDate
*/
public Date getDemandStartDate() {
return demand.getDemandStartDate();
}
/**
* setdemandStartDate
*
* @param demandStartDate
* the demandStartDate to set
*/
public void setDemandStartDate(Date demandStartDate) {
demand.setDemandStartDate(demandStartDate);
}
/**
* demandEndDate
*
* @return the demandEndDate
*/
public Date getDemandEndDate() {
return demand.getDemandEndDate();
}
/**
* setDemandEndDate
*
* @param demandEndDate
* the demandEndDate to set
*/
public void setDemandEndDate(Date demandEndDate) {
demand.setDemandEndDate(demandEndDate);
}
/**
* Demand
*
* @return {@link Demand}
*/
public Demand getDemand() {
return demand;
}
/**
* setDemand
*
* @param demand
* demand
*/
public void setDemand(Demand demand) {
this.demand = demand;
}
/**
* Label
*
* @return Label
*/
public String getLabel() {
return demand.getLabel();
}
/**
* label
* @param label label
*/
public void setLabel(String label) {
demand.setLabel(label);
}
/**
* contact
* @return contact
*/
public String getContact() {
return demand.getContact();
}
/**
* setContact
* @param contact contact
*/
public void setContact(String contact) {
demand.setContact(contact);
}
public String doSave() {
LOG.info(getDemand());
demandsManagerDelegate.save(demand);
toXML(demand);
// LOG.info(xml);
return SUCCESS;
}
} |