Fwd: WORepetition not displaying
Fwd: WORepetition not displaying
- Subject: Fwd: WORepetition not displaying
- From: Nathan Hampton <email@hidden>
- Date: Mon, 19 Apr 2004 10:23:48 -0500
I checked the rendered component's HTML syntax, and it's valid HTML
4.01 Transitional. I've attached the component files; the custom web
object ApplicationCommonElements has access control functions and HTML
elements reused across multiple components (<head> tag, navigation
elements, etc.).
--NCH
[demime 0.98b removed an attachment of type application/octet-stream which had a name of ReceiveStock.api]
// Generated by the WebObjects Assistant Thu Feb 12 08:24:41 America/Chicago 2004
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
public class ReceiveStock extends WOComponent
{
protected Bill bill;
private EOEditingContext ec = this.session().defaultEditingContext();
public ItemPrice itemPrice;
public BillLineItem lineItem;
public BillLineItem newLineItem;
public Double newRetailPrice;
public Double newWholesaleDiscount;
public PurchaseOrderLineItem openPOLine;
/** @TypeInfo PurchaseOrderLineItem */
public NSMutableArray openPOLines;
protected PersOrg vendor;
// Display Control Variables
protected boolean showBillDetailEntry = false;
public boolean showBillInformationEntry = false;
public boolean showVendorSelection = true;
public boolean showPOLineSelection = false;
public ReceiveStock(WOContext context)
{
super(context);
}
public void saveChanges() throws Exception
{
try
{
ec.saveChanges();
resetVariables();
}
catch (Exception exception) {
// An error occurred during the save. You could present an error page which
// explains the reason for the save failure.
// The default is to raise an exception which presents a diagnostic page.
NSLog.err.appendln("Cannot save changes ");
throw exception;
}
}
public WOComponent createNewShipmentForVendor()
{
// create bill, insert in editing context, set vendor
bill = new Bill();
ec.insertObject(bill);
bill.setVendor(vendor);
// set display control variables
showVendorSelection = false;
showBillInformationEntry = true;
return null;
}
public WOComponent selectPOLine()
{
// create new line item
newLineItem = new BillLineItem();
// set display control variables
showPOLineSelection = false;
return null;
}
public WOComponent cancelLineItemEdit()
{
newLineItem = null;
showPOLineSelection = true;
return null;
}
public WOComponent selectLineItem()
{
newLineItem = lineItem;
showPOLineSelection = false;
return null;
}
public WOComponent saveLineItem()
{
// assume no ItemPrice
boolean hasItemPriceEntry = false;
try
{
ItemPrice ip = newLineItem.associatedItemPriceEntry();
if (ip != null)
{
hasItemPriceEntry = true;
}
}
catch (NullPointerException e)
{
// NullPointerExceptions aren't a problem - they simply indicate that hasItemPriceEntry should remain false - so we can safely ignore them; the if-else block below will prevent further errors.
}
if (hasItemPriceEntry)
{
// get quantity on hand and quantity incoming
int had = newLineItem.associatedItemPriceEntry().quantityAvailable().intValue();
int incoming = newLineItem.quantityReceived().intValue();
// add quantity on hand and quantity incoming to get new quantity on hand
int have = had + incoming;
// set quantity on hand
newLineItem.associatedItemPriceEntry().setQuantityAvailable(new Integer(have));
}
// if no item price entry set, check to ensure values provided to create new ItemPrice
else if (newRetailPrice != null && newWholesaleDiscount != null)
{
// create new ItemPrice object and insert in editing context
itemPrice = (ItemPrice)EOUtilities.createAndInsertInstance(ec, "ItemPrice");
// set values for new ItemPrice object
itemPrice.setRetailPrice(newRetailPrice);
itemPrice.setWholesaleDiscount(newWholesaleDiscount);
itemPrice.setQuantityAvailable(newLineItem.quantityReceived());
// set ItemPrice for newLineItem to itemPrice
newLineItem.setAssociatedItemPriceEntry(itemPrice);
// add new ItemPrice object to item's array of ItemPrices
newLineItem.purchaseOrderLineItem().item().addToPricing(itemPrice);
}
// insert in editing context
ec.insertObject(newLineItem);
// set relationships
newLineItem.setPurchaseOrderLineItem(openPOLine);
openPOLine.addToBillLineItems(newLineItem);
if (!bill.lineItems().containsObject(newLineItem))
{
bill.addToLineItems(newLineItem);
}
// accounting stuff
// wholesale value increases inventory
// freight increases 5-4000
// fees increase 5-5200
// total bill increases 2-5200
// reset variables to prevent problems with next line item entered
newLineItem = null;
newRetailPrice = null;
newWholesaleDiscount = null;
// set display variables
showPOLineSelection = true;
return null;
}
public WOComponent removeLineItem()
{
ec.deleteObject(lineItem);
return null;
}
public WOComponent continueToBillDetails()
{
getOpenPOLines();
// set display control variables
showBillInformationEntry = false;
showBillDetailEntry = true;
showPOLineSelection = true;
return null;
}
public void getOpenPOLines()
{
// Local variables
NSArray vendorCurrentPurchaseOrders = bill.vendor().vndCurrentPurchaseOrders();
openPOLines = new NSMutableArray();
if (Application.debug)
{
System.out.println("vendorCurrentPurchaseOrders.count() = " + vendorCurrentPurchaseOrders.count());
System.out.println("openPOLines.count() = " + openPOLines.count());
}
// Iterate through PurchaseOrders
for (int poIndex = 0; poIndex < vendorCurrentPurchaseOrders.count(); poIndex++)
{
if (Application.debug)
{
System.out.println("poIndex = " + poIndex);
}
// Get PurchaseOrderLineItems for this iteration
NSArray poLines = ((PurchaseOrder)vendorCurrentPurchaseOrders.objectAtIndex(poIndex)).lineItems();
if (Application.debug)
{
System.out.println("poLines.count() = " + poLines.count());
}
// Iterate through PurchaseOrderLineItems
for (int lineIndex = 0; lineIndex < poLines.count(); lineIndex++)
{
if (Application.debug)
{
System.out.println("lineIndex = " + lineIndex);
System.out.println("((PurchaseOrderLineItem)poLines.objectAtIndex(lineIndex)).isOpen() returns " + ((PurchaseOrderLineItem)poLines.objectAtIndex(lineIndex)).isOpen());
}
// If PurchaseOrderLineItem for this iteration is open, add to list of open lines
if (((PurchaseOrderLineItem)poLines.objectAtIndex(lineIndex)).isOpen())
{
openPOLines.addObject((PurchaseOrderLineItem)poLines.objectAtIndex(lineIndex));
if (Application.debug)
{
PurchaseOrderLineItem L = (PurchaseOrderLineItem)poLines.objectAtIndex(lineIndex);
System.out.println("PurchaseOrderLineItem added to openPOLines with values partOf().poNumber() = " + L.partOf().poNumber() + ", item().itemNumber() = " + L.item().itemNumber() + "and quantityOpen() = " + L.quantityOpen());
}
}
if (Application.debug)
{
System.out.println("count of openPOLines = " + openPOLines.count());
}
}
}
}
public WOComponent cancelBillCreation()
{
// undo changes to editing context
ec.revert();
// reset local variables
bill = null;
vendor = null;
// Set Display Control Variables
resetVariables();
return null;
}
public void resetVariables()
{
showBillDetailEntry = false;
showBillInformationEntry = false;
showVendorSelection = true;
showPOLineSelection = false;
bill = null;
vendor = null;
newRetailPrice = null;
newWholesaleDiscount = null;
}
}
[demime 0.98b removed an attachment of type application/zip which had a name of ReceiveStock.wo.zip]
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.