cancel
Showing results for 
Search instead for 
Did you mean: 

How to add new items in WebCatItemPage?

Former Member
0 Kudos

hi,

My requirement is to modify "GetItemPageAction" to "ZGetItemPageAction".

in that i have to modify "myItemList".

so what i have done it i had created new Z_myItemList.

now if i add any item to this,i am getting some error.

z_item = (WebCatItem) myItemList.getItem(z_i);

z_myItemList.addItem(z_item);(on this line i am getting error).

if i put comment on above line everythign is working fine.

Regards,

jayesh talreja

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Try this :

CatalogBusinessObjectManager cbom = getCatalogBusinessObjectManager(userSessionData);

WebCatInfo catalog = cbom.getCatalog();

new WebCatItemList(catalog);

WebCatItemList z_myItemList = new WebCatItemList(catalog);

This will give you a fully initialized, emtpy WebCatItemList

Former Member
0 Kudos

I AM GETTING ERROR AS

#1#java.lang.NullPointerException

at com.bd.isa.catalog.actions.ZGetItemPageAction.doPerform(ZGetItemPageAction.java:130)

Former Member
0 Kudos

Hi Jayesh,

This log says there is error on line 130 of ZGetItemPageAction.

Can you paste the code from line 125 to line 135 from ZGetItemPageAction.

Regards,

Arshi

Former Member
0 Kudos

UserSessionData userSessionData = UserSessionData.getUserSessionData(request.getSession());

BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);

Z_ProductBOM mybom = (Z_ProductBOM) userSessionData.getBOM(Z_ProductBOM.ZPRODUCT_BOM);

String[] product_id = new String[myItemList.getNoOfMainItems()];

WebCatItemPage items = null;

WebCatItem z_item = null;

int z_i = 0;

for(z_i = 0;z_i<myItemList.getNoOfMainItems();z_i++)

{

z_item = (WebCatItem) myItemList.getItem(z_i);

product_id[z_i]=(String)z_item.getAttributeByKey(AttributeKeyConstants.PRODUCT);

(line number 130) z_myItemList.addItem(z_item);

}

//Table locs = mybom.getFUNC().getProductIDs(product_id);

Former Member
0 Kudos

You are adding items to a null object that is z_myItemList, initlalize it first before adding items to it.

Its difficult to correct the error without having the complete code and understanding the scenario.

Check if this code is of any help to you.


public ActionForward doPerform(
		ActionMapping actionMapping,
		ActionForm actionForm,
		HttpServletRequest request,
		HttpServletResponse response)
		throws IOException, ServletException {

		WebCatItem webCatItem =
			(WebCatItem) request.getAttribute(
				com.sap.isa.catalog.actions.ActionConstants.RA_WEBCATITEM);

		Iterator itemIterator = webCatItem.getCatalogItemAttributes();

		String productName = "";
		String wheelType = "";
		String endUse = "";
		while (itemIterator.hasNext()) {

			com.sap.isa.catalog.boi.IAttributeValue item =
				(com.sap.isa.catalog.boi.IAttributeValue) itemIterator.next();

			if (!item.getAttribute().isBase()
				&& item.getAttributeDescription() != null
				&& item.getAttributeName().indexOf("_") != 0) {

				if (item
					.getAttributeDescription()
					.equalsIgnoreCase(Zeropadding.productName)) {

					if (webCatItem.getAreaAttributes() != null
						&& webCatItem.getAreaAttributes().getDescription(
							item.getAttributeGuid(),
							item.getAsString())
							!= null) {

						productName =
							webCatItem.getAreaAttributes().getDescription(
								item.getAttributeGuid(),
								item.getAsString());

					} else {

						productName = item.getAsString();

					}
					if (!webCatItem
						.getAttribute("_" + item.getAttributeName())
						.equals("")) {

						productName =
							webCatItem.getAttribute(
								"_" + item.getAttributeName());

					}

				}

				if (item
					.getAttributeDescription()
					.equalsIgnoreCase(Zeropadding.wheelType)) {

					if (webCatItem.getAreaAttributes() != null
						&& webCatItem.getAreaAttributes().getDescription(
							item.getAttributeGuid(),
							item.getAsString())
							!= null) {
						System.out.println(
							"wheel_type Item Area Desc :"
								+ webCatItem.getAreaAttributes().getDescription(
									item.getAttributeGuid(),
									item.getAsString()));

						wheelType =
							webCatItem.getAreaAttributes().getDescription(
								item.getAttributeGuid(),
								item.getAsString());

					} else {

						wheelType = item.getAsString();

					}
					if (!webCatItem
						.getAttribute("_" + item.getAttributeName())
						.equals("")) {

						wheelType =
							webCatItem.getAttribute(
								"_" + item.getAttributeName());

					}

				}

				if (item
					.getAttributeDescription()
					.equalsIgnoreCase(Zeropadding.endUse)) {

					if (webCatItem.getAreaAttributes() != null
						&& webCatItem.getAreaAttributes().getDescription(
							item.getAttributeGuid(),
							item.getAsString())
							!= null) {

						endUse =
							webCatItem.getAreaAttributes().getDescription(
								item.getAttributeGuid(),
								item.getAsString());

					} else {

						endUse = item.getAsString();

					}
					if (!webCatItem
						.getAttribute("_" + item.getAttributeName())
						.equals("")) {

						endUse =
							webCatItem.getAttribute(
								"_" + item.getAttributeName());

					}

				}

			}
		}
		//request.setAttribute("itemAttributesIterator",itemIteratorCopy);
		UserSessionData userSessionData =
			UserSessionData.getUserSessionData(request.getSession());
		Z_CustomBusinessObjectManager customBOM =
			(Z_CustomBusinessObjectManager) userSessionData.getBOM(
				Z_CustomBusinessObjectManager.CUSTOM_BOM);
		Z_attributeDescValue z_attributeDescValue =
			customBOM.getZ_attributeDescbo().getAttrInfo(
				productName,
				wheelType,
				endUse);

		request.setAttribute("AttrDesc", z_attributeDescValue);
		return actionMapping.findForward("success");
	}

Regards,

Arshi

Former Member
0 Kudos

hi arshi,

thanks for your reply.

ya you are right my z_myItemList is empty.

WebCatItemList z_myItemList = null;

can you tell me how can initiallise to perticulat size.

then i guess my problem will get resolved.

thanks in advance.

jayesh talreja