How to render no data node as <node></node>? - jaxb

I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />. I want it to be <node></node>
here is my codes :
#XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
#XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
#XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
#XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
#XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
#XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
#XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
#XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
#XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
#XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
#XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String[] colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}

Related

issues with parcelable extension: getting unmarshalling unknown type code exception

long story short, I have one settlementItemeBase class as my father and two children. I want to make the father class parcelable so as extension happens, my two child classes be parcelable as well. I don't exactly know what I'm doing right or wrong. I searched little bit but nothing helped me.
here are my classes:
SettlementItemBase:
public class SettlementItemBase implements Parcelable{
public SettlementItemBase(){}
protected SettlementItemBase(Parcel in) {
}
public static final Creator<SettlementItemBase> CREATOR = new Creator<SettlementItemBase>() {
#Override
public SettlementItemBase createFromParcel(Parcel in) {
return new SettlementItemBase(in);
}
#Override
public SettlementItemBase[] newArray(int size) {
return new SettlementItemBase[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
}
}
first child class:
public class FirstClass extends SettlementItemBase {
private int id;
private int cardId;
private String cardNumber;
private String expDate;
private String currency;
private String url;
public FirstClass(){
id = 0;
cardId = 0;
cardNumber = "";
expDate = "";
currency = "";
url = "";
}
protected FirstClass(Parcel in) {
super(in);
id = in.readInt();
cardId = in.readInt();
cardNumber = in.readString();
expDate = in.readString();
currency = in.readString();
url = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeInt(cardId);
dest.writeString(cardNumber);
dest.writeString(expDate);
dest.writeString(currency);
dest.writeString(url);
}
public int getId() {
return id;
}
public int getCardId() {
return cardId;
}
public String getCardNumber() {
return cardNumber;
}
public String getExpDate() {
return expDate;
}
public String getCurrency() {
return currency;
}
public String getUrl() {
return url;
}
}
second child class:
public class SecondClass extends SettlementItemBase{
private int id;
private String currency;
private String accountNumber;
private String ibanNumber;
public SecondClass(int id, String currency,
String accountNumber, String ibanNumber){
this.id = id;
this.currency = currency;
this.accountNumber = accountNumber;
this.ibanNumber = ibanNumber;
}
protected SecondClass(Parcel in){
super(in);
id = in.readInt();
currency = in.readString();
accountNumber = in.readString();
ibanNumber = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(currency);
dest.writeString(accountNumber);
dest.writeString(ibanNumber);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCurrency() {
return currency;
}
public String getAccountNumber() {
return accountNumber;
}
public String getIbanNumber() {
return ibanNumber;
}
}
I'm passing and getting an ArrayList of both child class' items with intent putParcelableArrayListExtra and getParcelableArrayListExtra methods and get the following error:
Parcel android.os.Parcel#2d0fde33: Unmarshalling unknown type code 3276849 at offset 172
any help would be appreciated 3>
well I'm posting this for those who may run into the same problem as me.
the problem was solved after adding the Creator statement to the child classes.
for one of the child classes it would be like:
public static final Creator<FirstClass> CREATOR = new Creator<FirstClass>() {
#Override
public FirstClass createFromParcel(Parcel in) {
return new FirstClass(in);
}
#Override
public FirstClass[] newArray(int size) {
return new FirstClass[size];
}
};
hope this helps. 3>

response.body returns null using retrofit:2.3.0

my json data is this
{
"data":[
{
"id":"4",
"totalOpns":"40000",
"killedDrugPer":"320",
"arrestedDrugPer":"17683",
"houseVisited":"4000",
"userSurrenderers":"45000",
"pusherSurrenderers":"15000",
"totalSurrenderers":"60000",
"killedPNPPerOpns":"40",
"woundedPNPPerOpns":"70",
"killedAFPPerOpns":"100",
"woundedAFPPerOpns":"10",
"date":"2017-07-12 13:57:34.000"
}
]
}
and my data model is this
package com.androidtutorialpoint.retrofitandroid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class Student implements Serializable {
//Variables that are in our json
#SerializedName("id")
#Expose
private String id;
#SerializedName("totalOpns")
#Expose
private String totalOpns;
#SerializedName("killedDrugPer")
#Expose
private String killedDrugPer;
#SerializedName("arrestedDrugPer")
#Expose
private String arrestedDrugPer;
#SerializedName("houseVisited")
#Expose
private String houseVisited;
#SerializedName("userSurrenderers")
#Expose
private String userSurrenderers;
#SerializedName("pusherSurrenderers")
#Expose
private String pusherSurrenderers;
#SerializedName("totalSurrenderers")
#Expose
private String totalSurrenderers;
#SerializedName("killedPNPPerOpns")
#Expose
private String killedPNPPerOpns;
#SerializedName("woundedPNPPerOpns")
#Expose
private String woundedPNPPerOpns;
#SerializedName("killedAFPPerOpns")
#Expose
private String killedAFPPerOpns;
#SerializedName("woundedAFPPerOpns")
#Expose
private String woundedAFPPerOpns;
#SerializedName("date")
#Expose
private String date;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTotalOpns() {
return totalOpns;
}
public void setTotalOpns(String totalOpns) {
this.totalOpns = totalOpns;
}
public String getKilledDrugPer() {
return killedDrugPer;
}
public void setKilledDrugPer(String killedDrugPer) {
this.killedDrugPer = killedDrugPer;
}
public String getArrestedDrugPer() {
return arrestedDrugPer;
}
public void setArrestedDrugPer(String arrestedDrugPer) {
this.arrestedDrugPer = arrestedDrugPer;
}
public String getHouseVisited() {
return houseVisited;
}
public void setHouseVisited(String houseVisited) {
this.houseVisited = houseVisited;
}
public String getUserSurrenderers() {
return userSurrenderers;
}
public void setUserSurrenderers(String userSurrenderers) {
this.userSurrenderers = userSurrenderers;
}
public String getPusherSurrenderers() {
return pusherSurrenderers;
}
public void setPusherSurrenderers(String pusherSurrenderers) {
this.pusherSurrenderers = pusherSurrenderers;
}
public String getTotalSurrenderers() {
return totalSurrenderers;
}
public void setTotalSurrenderers(String totalSurrenderers) {
this.totalSurrenderers = totalSurrenderers;
}
public String getKilledPNPPerOpns() {
return killedPNPPerOpns;
}
public void setKilledPNPPerOpns(String killedPNPPerOpns) {
this.killedPNPPerOpns = killedPNPPerOpns;
}
public String getWoundedPNPPerOpns() {
return woundedPNPPerOpns;
}
public void setWoundedPNPPerOpns(String woundedPNPPerOpns) {
this.woundedPNPPerOpns = woundedPNPPerOpns;
}
public String getKilledAFPPerOpns() {
return killedAFPPerOpns;
}
public void setKilledAFPPerOpns(String killedAFPPerOpns) {
this.killedAFPPerOpns = killedAFPPerOpns;
}
public String getWoundedAFPPerOpns() {
return woundedAFPPerOpns;
}
public void setWoundedAFPPerOpns(String woundedAFPPerOpns) {
this.woundedAFPPerOpns = woundedAFPPerOpns;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
}
and the interface is this
package com.androidtutorialpoint.retrofitandroid;
import retrofit2.Call;
import retrofit2.http.GET;
public interface RetrofitObjectAPI {
/*
* Retrofit get annotation with our URL
* And our method that will return us details of student.
*/
// #GET("JSONTESTING/index.php")
#GET("getJson")
Call<Student> getStudentDetails();
}
and in my main is this
private void getRetrofitObject() {
HttpLoggingInterceptor.Level logLevel = HttpLoggingInterceptor.Level.BODY;
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(logLevel);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
// add your other interceptors …
// add logging as last interceptor
httpClient.addInterceptor(logging); // <-- this is the important line!
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build();
RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
Call<Student> call = service.getStudentDetails();
call.enqueue(new Callback<Student>() {
#Override
public void onResponse(Call<Student> call, Response<Student> response) {
try {
if (response.isSuccessful()) {
text_id_1.setText("StudentId : " + response.body().getId());
text_name_1.setText("StudentName : " + response.body().getTotalOpns());
text_marks_1.setText("StudentMarks : " + response.body().getArrestedDrugPer());
} else {
//unsuccessful response
}
} catch (Exception e) {
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
#Override
public void onFailure(Call<Student> call, Throwable t) {
Log.d("onFailure", t.toString());
}
});
}
and in my logcat is this, i can see the json data but on my response.body returns null.
logcat
What should I do?
You are getting a response but there is issue in deserialization.
Reason being the Call<Student> is not the type it will be serialized to becuase you are getting a List of Students(JSONArray).
add this class
MyResponse
public class MyResponse {
#SerializedName("data")
#Expose
private List<Student> data = null;
public List<Student> getData() {
return data;
}
public void setData(List<Student> data) {
this.data = data;
}
}
and change your call to:
#GET("getJson")
Call<MyResponse> getStudentDetails();
Now you will get response body
and how to retrive?
List<Student> students = response.body().getData();
This will do..:)

Unmarshalling jaxB doesn't work, objects null

I have a problem with jaxB. There is no exception and here is my xml ;
<event>
<event_datetimeGMT>2015-02-27 17:00</event_datetimeGMT>
<gamenumber>443364144</gamenumber>
<sporttype>Basketball</sporttype>
<league>Adriatic</league>
<IsLive>No</IsLive>
<participants>
<participant>
<participant_name>Cedevita</participant_name>
<contestantnum>1001</contestantnum>
<rotnum>1001</rotnum>
<visiting_home_draw>Home</visiting_home_draw>
</participant>
<participant>
<participant_name>Mega Leks</participant_name>
<contestantnum>1002</contestantnum>
<rotnum>1002</rotnum>
<visiting_home_draw>Visiting</visiting_home_draw>
</participant>
</participants>
<periods>
<period>
<period_number>0</period_number>
<period_description>Game</period_description>
<periodcutoff_datetimeGMT>2015-02-27 17:00</periodcutoff_datetimeGMT>
<period_status>I</period_status>
<period_update>open</period_update>
<spread_maximum>500</spread_maximum>
<moneyline_maximum>500</moneyline_maximum>
<total_maximum>500</total_maximum>
<moneyline>
<moneyline_visiting>583</moneyline_visiting>
<moneyline_home>-720</moneyline_home>
</moneyline>
<spread>
<spread_visiting>12</spread_visiting>
<spread_adjust_visiting>-104</spread_adjust_visiting>
<spread_home>-12</spread_home>
<spread_adjust_home>-106</spread_adjust_home>
</spread>
<total>
<total_points>164</total_points>
<over_adjust>-101</over_adjust>
<under_adjust>-109</under_adjust>
</total>
</period>
</periods>
here is main class ;
#XmlRootElement (name = "pinnacle_line_feed")
public class PinnacleLineFeed {
private Long PinnacleFeedTime;
private Long lastContest;
private Long lastGame;
private List<Event> events;
#XmlAttribute(name = "PinnacleFeedTime")
public Long getPinnacleFeedTime() {
return PinnacleFeedTime;
}
public void setPinnacleFeedTime(Long pinnacleFeedTime) {
PinnacleFeedTime = pinnacleFeedTime;
}
#XmlAttribute (name = "lastContest")
public Long getLastContest() {
return lastContest;
}
public void setLastContest(Long lastContest) {
this.lastContest = lastContest;
}
#XmlAttribute (name = "lastGame")
public Long getLastGame() {
return lastGame;
}
public void setLastGame(Long lastGame) {
this.lastGame = lastGame;
}
#XmlElement (name = "events")
public List<Event> getEvents() {
return events;
}
public void setEvents(List<Event> events) {
this.events = events;
}
}
you can see full xml from the url which i shared at my first post
and here is my pojos ;
public class Event {
private String event_datetimeGMT;
private Long gamenumber;
private String sporttype;
private String league;
private String IsLive;
private List<Participant> participants;
private List<Period> periods;
#XmlAttribute (name = "event_datetimeGMT")
public String getEvent_datetimeGMT() {
return event_datetimeGMT;
}
public void setEvent_datetimeGMT(String event_datetimeGMT) {
this.event_datetimeGMT = event_datetimeGMT;
}
#XmlAttribute (name = "gamenumber")
public Long getGamenumber() {
return gamenumber;
}
public void setGamenumber(Long gamenumber) {
this.gamenumber = gamenumber;
}
#XmlAttribute (name = "sporttype")
public String getSporttype() {
return sporttype;
}
public void setSporttype(String sporttype) {
this.sporttype = sporttype;
}
#XmlAttribute (name = "league")
public String getLeague() {
return league;
}
public void setLeague(String league) {
this.league = league;
}
#XmlAttribute (name = "IsLive")
public String getIsLive() {
return IsLive;
}
public void setIsLive(String isLive) {
this.IsLive = isLive;
}
#XmlElement(name = "participant")
public List<Participant> getParticipants() {
return participants;
}
public void setParticipants(List<Participant> participants) {
this.participants = participants;
}
#XmlElement(name = "period")
public List<Period> getPeriods() {
return periods;
}
public void setPeriods(List<Period> periods) {
this.periods = periods;
}
}
public class Participants {
private List<Participant> participants;
#XmlElement(name = "participant")
public List<Participant> getParticipants() {
return participants;
}
public void setParticipants(List<Participant> participants) {
this.participants = participants;
}
}
public class Participant {
private String participant_name;
private Long contestantnum;
private Long rotnum;
private String visiting_home_draw;
#XmlAttribute(name = "participant_name")
public String getParticipant_name() {
return participant_name;
}
public void setParticipant_name(String participant_name) {
this.participant_name = participant_name;
}
#XmlAttribute (name = "contestantnum")
public Long getContestantnum() {
return contestantnum;
}
public void setContestantnum(Long contestantnum) {
this.contestantnum = contestantnum;
}
#XmlAttribute (name = "rotnum")
public Long getRotnum() {
return rotnum;
}
public void setRotnum(Long rotnum) {
this.rotnum = rotnum;
}
#XmlAttribute (name = "visiting_home_draw")
public String getVisiting_home_draw() {
return visiting_home_draw;
}
public void setVisiting_home_draw(String visiting_home_draw) {
this.visiting_home_draw = visiting_home_draw;
}
}
public class Periods {
private List<Period> periods;
#XmlElement(name = "period")
public List<Period> getPeriods() {
return periods;
}
public void setPeriods(List<Period> periods) {
this.periods = periods;
}
}
public class Period {
private int period_number;
private String period_description;
private String periodcutoff_datetimeGMT;
private String period_status;
private String period_update;
private int spread_maximum;
private int moneyline_maximum;
private int total_maximum;
private Moneyline moneyline;
private Spread spread;
private Total total;
#XmlAttribute(name = "period_number")
public int getPeriod_number() {
return period_number;
}
public void setPeriod_number(int period_number) {
this.period_number = period_number;
}
#XmlAttribute(name = "period_description")
public String getPeriod_description() {
return period_description;
}
public void setPeriod_description(String period_description) {
this.period_description = period_description;
}
#XmlAttribute(name = "periodcutoff_datetimeGMT")
public String getPeriodcutoff_datetimeGMT() {
return periodcutoff_datetimeGMT;
}
public void setPeriodcutoff_datetimeGMT(String periodcutoff_datetimeGMT) {
this.periodcutoff_datetimeGMT = periodcutoff_datetimeGMT;
}
#XmlAttribute(name = "period_status")
public String getPeriod_status() {
return period_status;
}
public void setPeriod_status(String period_status) {
this.period_status = period_status;
}
#XmlAttribute(name = "period_update")
public String getPeriod_update() {
return period_update;
}
public void setPeriod_update(String period_update) {
this.period_update = period_update;
}
#XmlAttribute(name = "spread_maximum")
public int getSpread_maximum() {
return spread_maximum;
}
public void setSpread_maximum(int spread_maximum) {
this.spread_maximum = spread_maximum;
}
#XmlAttribute(name = "moneyline_maximum")
public int getMoneyline_maximum() {
return moneyline_maximum;
}
public void setMoneyline_maximum(int moneyline_maximum) {
this.moneyline_maximum = moneyline_maximum;
}
#XmlAttribute(name = "total_maximum")
public int getTotal_maximum() {
return total_maximum;
}
public void setTotal_maximum(int total_maximum) {
this.total_maximum = total_maximum;
}
#XmlElement (name = "moneyline")
public Moneyline getMoneyline() {
return moneyline;
}
public void setMoneyline(Moneyline moneyline) {
this.moneyline = moneyline;
}
#XmlElement (name = "spread")
public Spread getSpread() {
return spread;
}
public void setSpread(Spread spread) {
this.spread = spread;
}
#XmlElement (name = "total")
public Total getTotal() {
return total;
}
public void setTotal(Total total) {
this.total = total;
}
}
public class Moneyline {
private int moneyline_visiting;
private int moneyline_home;
#XmlAttribute(name = "moneyline_visiting")
public int getMoneyline_visiting() {
return moneyline_visiting;
}
public void setMoneyline_visiting(int moneyline_visiting) {
this.moneyline_visiting = moneyline_visiting;
}
#XmlAttribute(name = "moneyline_home")
public int getMoneyline_home() {
return moneyline_home;
}
public void setMoneyline_home(int moneyline_home) {
this.moneyline_home = moneyline_home;
}
}
public class Spread {
private int spread_visiting;
private int spread_adjust_visiting;
private int spread_home;
private int spread_adjust_home;
#XmlAttribute(name = "spread_visiting")
public int getSpread_visiting() {
return spread_visiting;
}
public void setSpread_visiting(int spread_visiting) {
this.spread_visiting = spread_visiting;
}
#XmlAttribute(name = "spread_adjust_visiting")
public int getSpread_adjust_visiting() {
return spread_adjust_visiting;
}
public void setSpread_adjust_visiting(int spread_adjust_visiting) {
this.spread_adjust_visiting = spread_adjust_visiting;
}
#XmlAttribute(name = "spread_home")
public int getSpread_home() {
return spread_home;
}
public void setSpread_home(int spread_home) {
this.spread_home = spread_home;
}
#XmlAttribute(name = "spread_adjust_home")
public int getSpread_adjust_home() {
return spread_adjust_home;
}
public void setSpread_adjust_home(int spread_adjust_home) {
this.spread_adjust_home = spread_adjust_home;
}
}
public class Total {
private int total_points;
private int over_adjust;
private int under_adjust;
#XmlAttribute(name = "total_points")
public int getTotal_points() {
return total_points;
}
public void setTotal_points(int total_points) {
this.total_points = total_points;
}
#XmlAttribute(name = "over_adjust")
public int getOver_adjust() {
return over_adjust;
}
public void setOver_adjust(int over_adjust) {
this.over_adjust = over_adjust;
}
#XmlAttribute(name = "under_adjust")
public int getUnder_adjust() {
return under_adjust;
}
public void setUnder_adjust(int under_adjust) {
this.under_adjust = under_adjust;
}
}
and my test method ;
private static void unmarshall() {
try {
JAXBContext jc = JAXBContext.newInstance(PinnacleLineFeed.class);
URL url = new URL("http://xml.pinnaclesports.com/pinnacleFeed.aspx?");
Unmarshaller unmarshaller = jc.createUnmarshaller();
PinnacleLineFeed pinnacleLineFeed = (PinnacleLineFeed) unmarshaller.unmarshal(url);
System.out.println("bakıcez");
} catch (Exception ex) {
ex.printStackTrace();
}
}
When i try to unmarshall this xml, all fields are null. And there is no exception. Can anyone help ?

Jaxb #Attribute error read attribute

I have the code and xml and xml and cannot read the xml and believe that it is for the attribute. how can I read the attribute?
This is the code:
#XmlRootElement(name = "reimpresiones")
public class RePrint {
private Integer id;
private String document;
private String numberDocument;
private String extraction;
private String client;
private String groupExtraction;
private String route;
private String deliveryNote;
private String date;
private List<RePrint> reprintList;
public RePrint() {
}
#XmlAttribute(name = "id")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
#XmlElement(name = "client")
public String getClient() {
return client;
}
public void setClient(String client) {
this.client = client;
}
#XmlElement(name = "document")
public String getDocument() {
return document;
}
public void setDocument(String document) {
this.document = document;
}
#XmlElement(name = "numberDocument")
public String getNumberDocument() {
return numberDocument;
}
public void setNumberDocument(String numberDocument) {
this.numberDocument = numberDocument;
}
#XmlElement(name = "extraction")
public String getExtraction() {
return extraction;
}
public void setExtraction(String extraction) {
this.extraction = extraction;
}
#XmlElement(name = "groupExtraction")
public String getGroupExtraction() {
return groupExtraction;
}
public void setGroupExtraction(String groupExtraction) {
this.groupExtraction = groupExtraction;
}
#XmlElement(name = "route")
public String getRoute() {
return route;
}
public void setRoute(String route) {
this.route = route;
}
#XmlElement(name = "deliveryNote")
public String getDeliveryNote() {
return deliveryNote;
}
public void setDeliveryNote(String deliveryNote) {
this.deliveryNote = deliveryNote;
}
#XmlElement(name = "date")
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
#XmlElement(name = "reimprension")
public List<RePrint> getReprintList() {
return reprintList;
}
public void setReprintList(List<RePrint> reprintList) {
this.reprintList = reprintList;
}
}
This is the xml where there is a list of elements. I want to read "id" but i cannot.
<reimpresiones>
<reimpresion id="10574691840591525620140557591784">
<document>MATRICULA</document>
<numdocument><![CDATA[M142849865 ]]></numdocument>
<groupExtraction>1849986</groupExtraction>
<extraction>919767</extraction>
<client>780</client>
<deliveryNote><![CDATA[3600445640/01 ]]></deliveryNote>
<route>BUY</route>
<date>2014-05-05-17.59.57.919200</date>
</reimpresion>
<reimpresion id="14081953280539172820140537251728">
<document>MATRICULA</document>
<numdocument><![CDATA[M142849864 ]]></numdocument>
<groupExtraction>1849986</groupExtraction>
<extraction>919767</extraction>
<client>780</client>
<deliveryNote><![CDATA[3600445640/01 ]]></deliveryNote>
<route>BUY</route>
<date>2014-05-05-17.25.37.427752</date>
</reimpresion>
</reimpresiones>
Thank you

#ManagedProperty - access properties Injected from one view scoped bean into another view scoped bean

I have injected one view scoped bean into another view scoped bean , and I can access some properties of the first bean but others appear as null in #PostContruct. How can I see their real value?
Thanks in advance
Update:
I can only see the value of properties updated in #PostContruct of the first bean and not others
Bean 1(SelectOfferMpans)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sofyc.backingbean.offer;
import es.iberdrola.configuration.LogginManager;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;
import sofyc.bean.BeanInstanceLocator;
import sofyc.bean.IOffersBean;
import sofyc.corejsf.SofycNavigation;
import sofyc.corejsf.SofycParamNames;
import sofyc.utils.JSFHelper;
import sofyc.valueobject.CustomerFindVO;
import sofyc.valueobject.MpanVO;
import sofyc.valueobject.OfferSitesVO;
#ManagedBean
#ViewScoped
public class SelectOfferMpans implements Serializable{
/**
* Logger.
*/
private static Logger log = LogginManager.getLogger(SelectOfferMpans.class.getName());
static {
adq_ren_types = new String[2];
}
private final String ID_OFFER_SELECT_MPANS_FORM = "selectMpans";
private String menuOrigin;
/**
* Parametro de busqueda del formulario.
*/
private String registrationNumber;
private List<CustomerFindVO> customerfoundList;
private CustomerFindVO customerfound;
private String companyRegNo;
private String customerId;
private CustomerFindVO selectedCustomer;
private List<OfferSitesVO> offerSites;
private List<OfferSitesVO> filteredSites;
private OfferSitesVO selectedSite;
private OfferSitesVO[] selectedSites;
private List<MpanVO> siteMpans;
private SelectItem[] hh_nhh_List;
private SelectItem[] adq_ren_List;
private final static String[] adq_ren_types;
private Map<String,String> hh_nhh_types;
public Map<String, String> getHh_nhh_types() {
return hh_nhh_types;
}
public void setHh_nhh_types(Map<String, String> hh_nhh_types) {
this.hh_nhh_types = hh_nhh_types;
}
public SelectItem[] getHh_nhh_List() {
return hh_nhh_List;
}
public void setHh_nhh_List(SelectItem[] hh_nhh_List) {
this.hh_nhh_List = hh_nhh_List;
}
public SelectItem[] getAdq_ren_List() {
return adq_ren_List;
}
public void setAdq_ren_List(SelectItem[] adq_ren_List) {
this.adq_ren_List = adq_ren_List;
}
public List<OfferSitesVO> getOfferSites() {
return offerSites;
}
public void setOfferSites(List<OfferSitesVO> offerSites) {
this.offerSites = offerSites;
}
public List<OfferSitesVO> getFilteredSites() {
return filteredSites;
}
public void setFilteredSites(List<OfferSitesVO> filteredSites) {
this.filteredSites = filteredSites;
}
public OfferSitesVO getSelectedSite() {
return selectedSite;
}
public void setSelectedSite(OfferSitesVO selectedSite) {
this.selectedSite = selectedSite;
}
public OfferSitesVO[] getSelectedSites() {
return selectedSites;
}
public void setSelectedSites(OfferSitesVO[] selectedSites) {
this.selectedSites = selectedSites;
}
public List<MpanVO> getSiteMpans() {
return siteMpans;
}
public void setSiteMpans(List<MpanVO> siteMpans) {
this.siteMpans = siteMpans;
}
public CustomerFindVO getSelectedCustomer() {
return selectedCustomer;
}
public void setSelectedCustomer(CustomerFindVO selectedCustomer) {
this.selectedCustomer = selectedCustomer;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getCompanyRegNo() {
return companyRegNo;
}
public void setCompanyRegNo(String companyRegNo) {
this.companyRegNo = companyRegNo;
}
public List<CustomerFindVO> getCustomerfoundList() {
return customerfoundList;
}
public void setCustomerfoundList(List<CustomerFindVO> customerfoundList) {
this.customerfoundList = customerfoundList;
}
public String getRegistrationNumber() {
return registrationNumber;
}
public void setRegistrationNumber(String registrationNumber) {
this.registrationNumber = registrationNumber;
}
public CustomerFindVO getCustomerfound() {
return customerfound;
}
public void setCustomerfound(CustomerFindVO customerfound) {
this.customerfound = customerfound;
}
public String getMenuOrigin() {
return menuOrigin;
}
public void setMenuOrigin(String menuOrigin) {
this.menuOrigin = menuOrigin;
}
/**
* Creates a new instance of SelectOfferMpans
*/
public SelectOfferMpans() {
}
#PostConstruct
public void init() {
try{
if(log.isDebugEnabled()) {
log.debug("INIT");
}
if (getMenuOrigin() == null) {
setMenuOrigin(JSFHelper.getParameterFromView("OPTION"));
if (getMenuOrigin() == null) {
setMenuOrigin((String) JSFHelper.getParameterFromRequest("OPTION"));
}
if (log.isDebugEnabled()) {
log.debug("CREATE OFFER --> guardado en VIEW VAR menuOrigin el "
+ "valor recuperado en la Request del parametro OPTION:: "
+ getMenuOrigin());
}
}
adq_ren_types[0] = "Adquisitions";
adq_ren_types[1] = "Renews";
this.setHh_nhh_types(cargaHHNHH());
//hh_nhh_List = createFilterOptions(hh_nhh_types);
hh_nhh_List = createFilterOptions1(hh_nhh_types,true);
adq_ren_List = createFilterOptions(adq_ren_types);
}catch(Exception e)
{
log.error("SearchCustomer:Init", e);
JSFHelper.addErrorMessage("messagesError", e.getMessage());
}
}
public void findCustomer() throws Exception {
CustomerFindVO customer=null;
try{
if (log.isDebugEnabled()) {
log.debug("Searching Customer....");
}
IOffersBean offersBean = BeanInstanceLocator.getOffersBean();
customerfound = offersBean.searchCustomer(companyRegNo);
if (customerfound!=null){
this.setOfferSites(offersBean.getCustomerSites(customerfound.getCustomerId()));
}
else{
this.setOfferSites(null);
JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error searching customer");
}
if (log.isDebugEnabled()) {
log.debug("Customer Data Found");
}
} catch (Throwable t) {
log.error("findCustomer:", t);
JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error searching customer");
}
}
public String goToOffers(){
try{
JSFHelper.addParamToRequest(SofycParamNames.CUSTOMER_ID, customerfound.getCustomerId());
JSFHelper.addParamToRequest(SofycParamNames.OPTION, this.getMenuOrigin());
return SofycNavigation.VIEW_CREATE_OFFERS_PAGE;
} catch (Throwable t) {
log.error("goToOffers:", t);
JSFHelper.addErrorMessage(ID_OFFER_SELECT_MPANS_FORM, "Error navigating to offers page");
return null;
}
}
private SelectItem[] createFilterOptions(String[] data) {
SelectItem[] options = new SelectItem[data.length + 1];
options[0] = new SelectItem("", "Select");
for(int i = 0; i < data.length; i++) {
options[i + 1] = new SelectItem(data[i], data[i]);
}
return options;
}
private SelectItem[] createFilterOptions1(Map<String,String> data, boolean select) {
//SelectItem[] options = new SelectItem[data.size() + 1];
SelectItem[] options;
int i = 0;
if (select==true) {
options = new SelectItem[data.size() + 1];
options[i] = new SelectItem("", "Select");
i++;
}
else{
options = new SelectItem[data.size()];
}
for (Map.Entry e: data.entrySet()) {
options[i] = new SelectItem(e.getKey().toString(), e.getValue().toString());
//options[i + 1] = new SelectItem(e.getValue().toString(),e.getKey().toString());
i++;
}
return options;
}
private Map<String,String> cargaHHNHH() {
Map<String,String> hh_nhh_types= new HashMap<String,String>();
hh_nhh_types.put("HH","HH");
hh_nhh_types.put("NHH","NHH");
return hh_nhh_types;
}
}
Bean 2(CreateOffer) property selectedSites of the first bean appears always as null and It's loaded in findCustomer Method.
package sofyc.backingbean.offer;
import es.iberdrola.configuration.LogginManager;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.apache.log4j.Logger;
import org.primefaces.event.SelectEvent;
import org.primefaces.event.ToggleEvent;
import org.primefaces.event.UnselectEvent;
import sofyc.bean.BeanInstanceLocator;
import sofyc.bean.IOffersBean;
import sofyc.utils.JSFHelper;
import sofyc.valueobject.CustomerVO;
import sofyc.valueobject.MddMeasurementClassVO;
import sofyc.valueobject.MpanVO;
import sofyc.valueobject.OfferSitesVO;
import sofyc.valueobject.ProfileClassVO;
import sofyc.valueobject.SiteVO;
import sofyc.valueobject.TradebookVO;
#ManagedBean
#ViewScoped
public class CreateOffer implements Serializable {
private static Logger log = LogginManager.getLogger(CreateOffer.class.getName());
/**
* Creates a new instance of CreateOffer
*/
static {
adq_ren_types = new String[2];
}
#ManagedProperty(value="#{selectOfferMpans.selectedSites}")
//#ManagedProperty(value="#{selectOfferMpans}")
//private SelectOfferMpans selectOfferMpans;
private OfferSitesVO[] selectedSites;
/*public void setSelectOfferMpans(SelectOfferMpans selectOfferMpans) {
this.selectOfferMpans = selectOfferMpans;
}*/
public void setSelectedSites(OfferSitesVO[] selectedSites) {
this.selectedSites = selectedSites;
}
/**
* Valores posibles de donde viene la pagina.
*/
private final String CREATE_OFFERS_OPTION = "CREATE";
private final String OFFERS_OPTION = "OFFERS";
private String menuOrigin;
/**
* Corresponde a la columna CUSTOMER_ID.
*/
private Integer customerId;
private Map<String,String> managers;
private Date offerFromDate;
private Date offerToDate;
private Date expiryDate;
private Integer tradeBookId;
private String creditScore;
private String consultantMargin;
private String spMargin;
private Integer productId;
private Integer profileClassId;
private String measurementClassId;
private Integer curveId;
/**
* Customer selected.
*/
private CustomerVO customer;
private List<OfferSitesVO> offerSites;
private List<OfferSitesVO> filteredSites;
private OfferSitesVO selectedSite;
private OfferSitesVO[] selectedSites1;
public OfferSitesVO[] getSelectedSites1() {
return selectedSites1;
}
public void setSelectedSites1(OfferSitesVO[] selectedSites1) {
this.selectedSites1 = selectedSites1;
}
private List<MpanVO> siteMpans;
//private final static String[] hh_nhh_types;
private Map<String,String> hh_nhh_types;
private final static String[] adq_ren_types;
//private final static String[] cotOfferTypes;
private Map<String,String> cotOfferTypes;
private Map<String,String> offerType;
private Map<String,String> loadCurve;
//private final static String[] offerType;
//private final static String[] loadCurve;
private SelectItem[] hh_nhh_List;
private SelectItem[] adq_ren_List;
private SelectItem[] cotOfferList;
private String cotOfferSelection;
private String comcOfferSelection;
private String copcOfferSelection;
private String offerTypeSelection;
private String loadCurveSelection;
//La oferta es de tipo HH o NHH
private String offerHH_NHH;
private SelectItem[] offerTypeList;
private SelectItem[] loadCurveList;
/**
* Site selected.
*/
private SiteVO site;
private MpanVO mpan;
private List<SiteVO> sites;
private List<MpanVO> mpans;
private List<TradebookVO> tradeBookList;
private Map<String,Integer> ProductList;
private List<ProfileClassVO> profileClassList;
private List<MddMeasurementClassVO> measurementClassList;
private Map<String,Integer> CurveList;
#PostConstruct
public void init() {
if(log.isDebugEnabled()) {
log.debug("********************** CreateOffer::init **********************");
}
if (getMenuOrigin() == null) {
setMenuOrigin(JSFHelper.getParameterFromView("OPTION"));
if (getMenuOrigin() == null) {
setMenuOrigin((String) JSFHelper.getParameterFromRequest("OPTION"));
}
if (log.isDebugEnabled()) {
log.debug("CREATE OFFER --> guardado en VIEW VAR menuOrigin el "
+ "valor recuperado en la Request del parametro OPTION:: "
+ getMenuOrigin());
}
}
adq_ren_types[0] = "Adquisitions";
adq_ren_types[1] = "Renews";
//Valor por defecto de COT
cotOfferSelection="0";
//Valor por defecto de COMC
comcOfferSelection="0";
//Valor por defecto de COPC
copcOfferSelection="0";
//Valor por defecto de OfferType
offerTypeSelection="0";
//Valor por defecto de loadCurve
loadCurveSelection="0";
offerHH_NHH="NHH";
this.setHh_nhh_types(cargaHHNHH());
//hh_nhh_List = createFilterOptions(hh_nhh_types);
hh_nhh_List = createFilterOptions1(hh_nhh_types,true);
adq_ren_List = createFilterOptions(adq_ren_types);
//cotOfferList = createFilterOptions(cotOfferTypes);
this.setCotOfferTypes(cargaCOT());
cotOfferList = createFilterOptions1(cotOfferTypes,false);
this.setOfferType(cargaofferType());
offerTypeList = createFilterOptions1(offerType,false);
this.setLoadCurve(cargaloadCurve());
loadCurveList = createFilterOptions1(loadCurve,false);
populateRequestParamsInViewVars();
initCustomerInfo();
CurveList = new LinkedHashMap<String,Integer>();
ProductList = new LinkedHashMap<String,Integer>();
//hh_nhh_List = new LinkedHashMap<String,Integer>();
profileClassId=2;
measurementClassId="A";
curveId=1;
tradeBookId=3;
profileClassList = new ArrayList<ProfileClassVO>();
measurementClassList = new ArrayList<MddMeasurementClassVO>();
tradeBookList = new ArrayList<TradebookVO>();
loadProfileClass();
loadMeasurementClass();
loadTradeBook();
}
public void onRowSelect(SelectEvent event) {
//FacesMessage msg = new FacesMessage("Car Selected", ((Car) event.getObject()).getModel());
//FacesContext.getCurrentInstance().addMessage(null, msg);
//event.getComponent().
}
public void onRowUnselect(UnselectEvent event) {
//FacesMessage msg = new FacesMessage("Car Unselected", ((Car) event.getObject()).getModel());
//FacesContext.getCurrentInstance().addMessage(null, msg);
}
public String getOfferTypeSelection() {
return offerTypeSelection;
}
public void setOfferTypeSelection(String offerTypeSelection) {
this.offerTypeSelection = offerTypeSelection;
}
public String getLoadCurveSelection() {
return loadCurveSelection;
}
public void setLoadCurveSelection(String loadCurveSelection) {
this.loadCurveSelection = loadCurveSelection;
}
public SelectItem[] getOfferTypeList() {
return offerTypeList;
}
public void setOfferTypeList(SelectItem[] offerTypeList) {
this.offerTypeList = offerTypeList;
}
public SelectItem[] getLoadCurveList() {
return loadCurveList;
}
public void setLoadCurveList(SelectItem[] loadCurveList) {
this.loadCurveList = loadCurveList;
}
public List<ProfileClassVO> getProfileClassList() {
return profileClassList;
}
public void setProfileClassList(List<ProfileClassVO> ProfileClassList) {
this.profileClassList = ProfileClassList;
}
public MpanVO getMpan() {
return mpan;
}
public void setMpan(MpanVO mpan) {
this.mpan = mpan;
}
public List<MpanVO> getMpans() {
return mpans;
}
public void setMpans(List<MpanVO> mpans) {
this.mpans = mpans;
}
public List<SiteVO> getSites() {
return sites;
}
public void setSites(List<SiteVO> sites) {
this.sites = sites;
}
public CustomerVO getCustomer() {
return customer;
}
public void setCustomer(CustomerVO customer) {
this.customer = customer;
}
public SiteVO getSite() {
return site;
}
public void setSite(SiteVO site) {
this.site = site;
}
public String getCreditScore() {
return creditScore;
}
public void setCreditScore(String creditScore) {
this.creditScore = creditScore;
}
public String getConsultantMargin() {
return consultantMargin;
}
public void setConsultantMargin(String consultantMargin) {
this.consultantMargin = consultantMargin;
}
public String getSpMargin() {
return spMargin;
}
public void setSpMargin(String spMargin) {
this.spMargin = spMargin;
}
public List<OfferSitesVO> getOfferSites() {
return offerSites;
}
public void setOfferSites(List<OfferSitesVO> offerSites) {
this.offerSites = offerSites;
}
public List<OfferSitesVO> getFilteredSites() {
return filteredSites;
}
public void setFilteredSites(List<OfferSitesVO> filteredSites) {
this.filteredSites = filteredSites;
}
public SelectItem[] getAdq_ren_List() {
return adq_ren_List;
}
public void setAdq_ren_List(SelectItem[] adq_ren_List) {
this.adq_ren_List = adq_ren_List;
}
public SelectItem[] getHh_nhh_List() {
return hh_nhh_List;
}
public void setHh_nhh_List(SelectItem[] hh_nhh_List) {
this.hh_nhh_List = hh_nhh_List;
}
public Map<String, String> getHh_nhh_types() {
return hh_nhh_types;
}
public void setHh_nhh_types(Map<String, String> hh_nhh_types) {
this.hh_nhh_types = hh_nhh_types;
}
public Map<String, String> getOfferType() {
return offerType;
}
public void setOfferType(Map<String, String> offerType) {
this.offerType = offerType;
}
public Map<String, String> getLoadCurve() {
return loadCurve;
}
public void setLoadCurve(Map<String, String> loadCurve) {
this.loadCurve = loadCurve;
}
public String getOfferHH_NHH() {
return offerHH_NHH;
}
public void setOfferHH_NHH(String OfferHH_NHH) {
this.offerHH_NHH = OfferHH_NHH;
}
public String getMenuOrigin() {
return menuOrigin;
}
public void setMenuOrigin(String menuOrigin) {
this.menuOrigin = menuOrigin;
}
/**
* Metodo que inicializa los valores del cliente.
*/
private void initCustomerInfo() {
this.setSites(new ArrayList<SiteVO>());
this.setMpans(new ArrayList<MpanVO>());
List<OfferSitesVO> offerSitesAux = new ArrayList<OfferSitesVO>();
FacesMessage msg = null;
try{
log.debug("initCustomerInfo: Start");
IOffersBean offerBean = BeanInstanceLocator.getOffersBean();
this.setCustomer(offerBean.getCustomer(customerId));
this.setManagers(offerBean.getManagerList());
if (CREATE_OFFERS_OPTION.equals(menuOrigin)){
if (selectedSites!=null){
for(int i = 0; i < selectedSites.length; i++){
offerSitesAux.add(selectedSites[i]);
}
}
this.setOfferSites(offerSitesAux);
}
else{
this.setOfferSites(offerBean.getCustomerSites(customerId));
}
this.setHh_nhh_List(offerBean.getHHNHHList());
this.setAdq_ren_List(offerBean.getAdquisitionRenewList());
}catch(Exception e){
msg = new FacesMessage("ERROR "+e.getMessage());
FacesContext.getCurrentInstance().addMessage(null, msg);
log.error("ERROR 2:: "+e.getMessage());
}
}
public Integer getProductId() {
return productId;
}
public void setProductId(Integer ProductId) {
this.productId = ProductId;
}
public List<TradebookVO> getTradeBookList() {
return tradeBookList;
}
public void setTradebookList(List<TradebookVO> tradeBookList) {
this.tradeBookList = tradeBookList;
}
public List<MddMeasurementClassVO> getMeasurementClassList() {
return measurementClassList;
}
public void setMeasurementClassList(List<MddMeasurementClassVO> MeasurementClassList) {
this.measurementClassList = MeasurementClassList;
}
public Integer getProfileClassId() {
return profileClassId;
}
public void setProfileClassId(Integer ProfileClassId) {
this.profileClassId = ProfileClassId;
}
public String getMeasurementClassId() {
return measurementClassId;
}
public void setMeasurementClassId(String MeasurementClassId) {
this.measurementClassId = MeasurementClassId;
}
public Integer getCurveId() {
return curveId;
}
public void setCurveId(Integer CurveId) {
this.curveId = CurveId;
}
public Integer getCustomerId() {
return customerId;
}
public void setCustomerId(Integer customerId) {
this.customerId = customerId;
}
public Date getOfferFromDate() {
return offerFromDate;
}
public void setOfferFromDate(Date OfferFromDate) {
this.offerFromDate = OfferFromDate;
}
public Date getOfferToDate() {
return offerToDate;
}
public void setOfferToDate(Date OfferToDate) {
this.offerToDate = OfferToDate;
}
public Integer getTradeBookId() {
return tradeBookId;
}
public void setTradeBookId(Integer tradeBookId) {
this.tradeBookId = tradeBookId;
}
public Map<String, String> getManagers() {
return managers;
}
public void setManagers(Map<String, String> managers) {
this.managers = managers;
}
public OfferSitesVO getSelectedSite() {
return selectedSite;
}
public void setSelectedSite(OfferSitesVO selectedSite) {
this.selectedSite = selectedSite;
}
public OfferSitesVO[] getSelectedSites() {
return selectedSites;
}
public List<MpanVO> getSiteMpans() {
return siteMpans;
}
public void setSiteMpans(List<MpanVO> siteMpans) {
this.siteMpans = siteMpans;
}
public String getCopcOfferSelection() {
return copcOfferSelection;
}
public void setCopcOfferSelection(String copcOfferSelection) {
this.copcOfferSelection = copcOfferSelection;
}
public String getComcOfferSelection() {
return comcOfferSelection;
}
public void setComcOfferSelection(String comcOfferSelection) {
this.comcOfferSelection = comcOfferSelection;
}
public Map<String, String> getCotOfferTypes() {
return cotOfferTypes;
}
public void setCotOfferTypes(Map<String, String> cotOfferTypes) {
this.cotOfferTypes = cotOfferTypes;
}
public String getCotOfferSelection() {
return cotOfferSelection;
}
public void setCotOfferSelection(String cotOfferSelection) {
this.cotOfferSelection = cotOfferSelection;
}
public Date getExpiryDate() {
return expiryDate;
}
public void setExpiryDate(Date expiryDate) {
this.expiryDate = expiryDate;
}
public SelectItem[] getCotOfferList() {
return cotOfferList;
}
public void setCotOfferList(SelectItem[] cotOfferList) {
this.cotOfferList = cotOfferList;
}
private void loadProfileClass() {
FacesMessage msg = null;
try{
log.debug("ProfileClass: Start");
IOffersBean offerBean = BeanInstanceLocator.getOffersBean();
List ProfileClassLista = offerBean.getProfileClassList(offerHH_NHH);
this.setProfileClassList((ArrayList<ProfileClassVO>) ProfileClassLista);
if(ProfileClassLista == null){
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,"There are not Profile_class elements",null);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
log.debug("ProfileClassLista: end");
}catch(Exception e){
msg = new FacesMessage("ERROR "+e.getMessage());
FacesContext.getCurrentInstance().addMessage(null, msg);
log.error("ERROR 2:: "+e.getMessage());
}
}
private void loadMeasurementClass() {
FacesMessage msg;
try{
log.debug("MeasurementClass: Start");
IOffersBean offerBean = BeanInstanceLocator.getOffersBean();
List MeasureClassList = offerBean.getMeasurementClassList();
this.setMeasurementClassList((ArrayList<MddMeasurementClassVO>) MeasureClassList);
if(measurementClassList == null){
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,"There are not Measurement_class elements",null);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
log.debug("loadMeasurementClass: end");
}catch(Exception e){
msg = new FacesMessage("ERROR "+e.getMessage());
FacesContext.getCurrentInstance().addMessage(null, msg);
log.error("ERROR 2:: "+e.getMessage());
}
}
}
I have injected one request scoped bean into another view scoped bean
You're not allowed to inject a bean into another bean of a wider scope.
As a rule, the following abominations are not allowed :)
#RequestScoped >> #ViewScoped
#ViewScoped >>#SessionScoped
#SessionScoped >> #ApplicationScoped
EDIT (Based on your update): Injecting a property of a bean, as against injecting the bean itself, will result in a static injection. The static injection means that the value that's injected into the target is what's available as at the time of injection. As a the time the following line was executed:
#ManagedProperty(value="#{selectOfferMpans.selectedSites}")
selectedSites is null. So what you should be doing there instead is injecting the entire bean
#ManagedProperty(value="#{selectOfferMpans}")
This way, you'll have access to the current value of whatever variable you're interested in

Resources