<%{%>
<%@ page import="com.bmw.internetm.silo.framework.common.*" %>
<%@ page import="com.bmw.internetm.silo.framework.common.utils.*" %>
<%@ page import="com.bmw.internetm.silo.framework.configuration.*" %>
<%@ page import="com.bmw.internetm.silo.adapter.four.mapping.campaign.*" %>
<%@ page import="com.bmw.internetm.silo.adapter.four.logic.*" %>
<%@ page import="com.bmw.four.service.FourAttributeCatalog" %>
<%@ page import="com.bmw.four.*" %>
<%@ page import="java.util.*" %>
<%@ include file="../../../../_common/_includes/forms.inc.jsp" %>
<%}%>
<%String country=null;country="es";%>
<%String language=null;language="es";%>
<%String step1_pixels=null;step1_pixels="";%>
<%String step2_pixels=null;step2_pixels="";%>
<%String step3_pixels=null;step3_pixels="";%>
<%java.lang.StringBuffer setCounters=null;%>
<%com.bmw.internetm.silo.jsptools.form.FormBuilder fb=null;%>
<%com.bmw.internetm.silo.framework.common.SiloLocale sl=null;%>
<%java.util.LinkedList allMats=null;%>
<%{%>
<%
sl = new SiloLocale(country, language);
allMats = (LinkedList) session.getAttribute("infomaterials");
if (allMats == null) {
allMats = new LinkedList();
Campaign mc = null;
Value[] groups = null;
mc = CampaignFactory.getMasterCampaign(sl);
if (mc == null) throw new com.bmw.internetm.silo.framework.exception.InvalidConfigurationException("Locale has no MasterCampaign!");
if (!mc.isSynchronizedWithEcom()) throw new com.bmw.internetm.silo.framework.exception.InvalidConfigurationException("MasterCampaign is not eCOM Campaign!");
groups = ValueHome.findOptions(com.bmw.four.service.FourAttributeCatalog.ATTR_NO_RFI_GROUP_NAME, sl.getCountryCode(), sl.getLanguageCode(), mc.getCampaignPhaseNo());
for (int i=0; i < groups.length; i++) { //iterate over infomaterial groups
int gNo = Integer.parseInt(groups[i].getIdentifier());
Value[] mats = ValueHome.findOptions(gNo, FourAttributeCatalog.ATTR_NO_RFI_INFOMATERIAL_NAME, sl.getCountryCode(), sl.getLanguageCode(), mc.getCampaignPhaseNo());
for (int j=0; j < mats.length; j++) { //and infomaterials within the group
int soNo = Integer.parseInt(mats[j].getIdentifier());
Value[] matCode = ValueHome.findOptions(soNo, FourAttributeCatalog.ATTR_NO_RFI_INFOMATERIAL_CODE, sl.getCountryCode(), sl.getLanguageCode(), mc.getCampaignPhaseNo());
allMats.add(new String[] { groups[i].getValue(), matCode[0].getValue(), mats[j].getValue() } );
}
}
session.setAttribute("infomaterials", allMats);
}
%>
<%}%>
<%{%><%
String formName = "rfi";
RequestData requestData = createRequestData(formName, request);
requestData.setSiloLocale(sl);
//execute whatever action
Result result = perform(requestData, response);
fb = init(requestData, result, response);
printAdditionalHead(fb, out, country, language);
RequestParameters params = requestData.getRequestParameters();
setCounters = new StringBuffer();
String action = requestData.getAction();
String preselected_info_id = request.getParameter("infomaterial_id");
if (preselected_info_id == null) {
//used by IO flashes
preselected_info_id = request.getParameter("information_id");
}
if (chooseFormPartDisplay(requestData.getAction(), fb, out, request, result, formName)) {
return; //success and redirect
}
//for validation failures: restore the non-silo elements on this page by available form data:
FormSection sec = fb.getSection( "select");
Iterator it = sec.iterator();
Set selectedIds = new HashSet();
//identify selected infomaterials
while( it.hasNext()) {
FormElement ele = (FormElement) it.next();
String element_name = ele.getName();
int last_underscore = element_name.lastIndexOf("_") + 1;
if (last_underscore == -1) continue;
String key = element_name.substring(last_underscore);
if( element_name.startsWith( "ecom_rfi_material")) {
if( "true".equalsIgnoreCase( ele.getCurrentValue())) {
//set by form
selectedIds.add(key);
}
}
else if (element_name.startsWith("material_id_")) {
if (preselected_info_id == null) continue;
if (preselected_info_id.equals(ele.getCurrentValue())) {
//set by url parameter
selectedIds.add(key);
}
}
}
it = selectedIds.iterator();
setCounters = new StringBuffer("");
String bcId = "";
String mod_nav = "";
if (request.getParameter("bcId") != null) {
bcId = "&bcId=" + request.getParameter("bcId");
}
if (request.getParameter("mod_nav") != null) {
mod_nav = "&mod_nav=" + request.getParameter("mod_nav");
}
// next line: hack to append breadcrumb and module navigation parameters to
<%= fb.getClosingTag() %>
<%}%>