use of org.compiere.model.MAdvertisement in project adempiere by adempiere.
the class AdvertisementServlet method doPost.
// doGet
/**************************************************************************
* Process the HTTP Post request
*
* @param request request
* @param response response
* @throws ServletException
* @throws IOException
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.info("Post from " + request.getRemoteHost() + " - " + request.getRemoteAddr());
// Get Session attributes
HttpSession session = request.getSession(true);
session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
//
Properties ctx = JSPEnv.getCtx(request);
WebUser wu = (WebUser) session.getAttribute(WebUser.NAME);
if (wu == null) {
log.warning("No web user");
if (!response.isCommitted())
// entry
response.sendRedirect("loginServlet?ForwardTo=advertisement.jsp");
return;
}
int W_Advertisement_ID = WebUtil.getParameterAsInt(request, P_ADVERTISEMENT_ID);
MAdvertisement ad = new MAdvertisement(ctx, W_Advertisement_ID, null);
if (ad.get_ID() == 0) {
WebUtil.createForwardPage(response, "Web Advertisement Not Found", "advertisements.jsp", 0);
return;
}
StringBuffer info = new StringBuffer();
//
String Name = WebUtil.getParameter(request, "Name");
if (Name != null && Name.length() > 0 && !Name.equals(ad.getName())) {
ad.setName(Name);
info.append("Name - ");
}
String Description = WebUtil.getParameter(request, "Description");
if (Description != null && Description.length() > 0 && !Description.equals(ad.getDescription())) {
ad.setDescription(Description);
info.append("Description - ");
}
String ImageURL = null;
String AdText = WebUtil.getParameter(request, "AdText");
if (AdText != null && AdText.length() > 0 && !AdText.equals(ad.getAdText())) {
ad.setAdText(AdText);
info.append("AdText - ");
}
String ClickTargetURL = WebUtil.getParameter(request, "ClickTargetURL");
if (ClickTargetURL != null && ClickTargetURL.length() > 0 && !ClickTargetURL.equals(ad.getClickTargetURL())) {
ad.setClickTargetURL(ClickTargetURL);
info.append("ClickTargetURL - ");
}
if (info.length() > 0) {
if (ad.save())
WebUtil.createForwardPage(response, "Web Advertisement Updated: " + info.toString(), "advertisements.jsp", 0);
else
WebUtil.createForwardPage(response, "Web Advertisement Update Error", "advertisements.jsp", 0);
} else
WebUtil.createForwardPage(response, "Web Advertisement not changed", "advertisements.jsp", 0);
}
use of org.compiere.model.MAdvertisement in project adempiere by adempiere.
the class WebInfo method getAdvertisements.
// getInterests
/**
* Get Advertisements
* @return advertisements of BP
*/
public ArrayList<MAdvertisement> getAdvertisements() {
m_infoMessage = null;
ArrayList<MAdvertisement> list = new ArrayList<MAdvertisement>();
String sql = "SELECT * FROM W_Advertisement WHERE C_BPartner_ID=? ORDER BY ValidFrom DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getC_BPartner_ID());
rs = pstmt.executeQuery();
while (rs.next()) list.add(new MAdvertisement(m_ctx, rs, null));
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("#" + list.size());
return list;
}
use of org.compiere.model.MAdvertisement in project adempiere by adempiere.
the class WebInfo method getAllAds.
// getAdvertisement
/**
* Get All Advertisements
* @return all advertisements
*/
public ArrayList<MAdvertisement> getAllAds() {
m_infoMessage = null;
ArrayList<MAdvertisement> list = new ArrayList<MAdvertisement>();
String sql = "SELECT * FROM W_Advertisement WHERE IsActive='Y' ORDER BY Description";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) list.add(new MAdvertisement(m_ctx, rs, null));
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
log.fine("#" + list.size());
return list;
}
Aggregations