ResolveParameter is a very important class when implementing custom code in commerce and I am sure, it is a very important tool for commerce developers doing custom implementations. When a custom implementation requires to post multiple name/value pairs of the same type, this class is really useful.
e.g. URL params
catentryId_12343=value1,catentryId_22343=value2,catentryId_32343=value3
orderItemStatus_10000=value10001,orderitemsStatus_10004=value
//resolve params in request properties, returns the hashtable of name, value pairs.
public void setRequestProperties(TypedProperty reqProperties) throws ECException {
ihshCatentry_id = ResolveParameter.resolveValues(OrderConstants.EC_CATENTRY_ID, requestProperties, false);
}
Couple of other methods from ResolveParameter that I find useful from time to time.
/*
* returns the order item status from the hash table using the resolve parameter method.
*/
protected String getOrderItemStatus(Integer i, Hashtable hashOrderItemStatus )
throws InvalidParameterValueException
{
String methodName = "getOrderItemStatus";
String orderItemStatus;
try
{
orderItemStatus = ResolveParameter.getString(i, hashOrderItemStatus);
} catch (NumberFormatException ex) {
throw new InvalidParameterValueException("orderItemId",
ex.getMessage());
}
return orderItemStatus;
}
/*
* returns the order item item id from the hash table using the resolve parameter method.
*/
protected Long getOrderItemId(Integer i, Hashtable hashOrderitemId )
throws InvalidParameterValueException
{
Long orderItemId;
try
{
orderItemId = ResolveParameter.getLong(i, hashOrderitemId);
} catch (NumberFormatException ex) {
throw new InvalidParameterValueException("orderItemId",
ex.getMessage());
}
return orderItemId;
}
e.g. URL params
catentryId_12343=value1,catentryId_22343=value2,catentryId_32343=value3
orderItemStatus_10000=value10001,orderitemsStatus_10004=value
//resolve params in request properties, returns the hashtable of name, value pairs.
public void setRequestProperties(TypedProperty reqProperties) throws ECException {
ihshCatentry_id = ResolveParameter.resolveValues(OrderConstants.EC_CATENTRY_ID, requestProperties, false);
}
Couple of other methods from ResolveParameter that I find useful from time to time.
/*
* returns the order item status from the hash table using the resolve parameter method.
*/
protected String getOrderItemStatus(Integer i, Hashtable hashOrderItemStatus )
throws InvalidParameterValueException
{
String methodName = "getOrderItemStatus";
String orderItemStatus;
try
{
orderItemStatus = ResolveParameter.getString(i, hashOrderItemStatus);
} catch (NumberFormatException ex) {
throw new InvalidParameterValueException("orderItemId",
ex.getMessage());
}
return orderItemStatus;
}
/*
* returns the order item item id from the hash table using the resolve parameter method.
*/
protected Long getOrderItemId(Integer i, Hashtable hashOrderitemId )
throws InvalidParameterValueException
{
Long orderItemId;
try
{
orderItemId = ResolveParameter.getLong(i, hashOrderitemId);
} catch (NumberFormatException ex) {
throw new InvalidParameterValueException("orderItemId",
ex.getMessage());
}
return orderItemId;
}
Enhorabuena por el artículo, muy buena redacción, se nota claramente que le pones esfuerzo y ganas.
ReplyDeleteMuy buen post, gracias por compartir esta información, sin duda seguiré esperando a que subas más contenido.
ReplyDelete