Primefaces Schedule adding data to event - jsf

I can't seem to get data into an event
public LeadListScheduleController() throws ParseException {
eventModel = new DefaultScheduleModel();
for (int i = 0; i < leadList.size(); i++)
{
if((leadList.get(i).next_action != null && !leadList.get(i).next_action.isEmpty())&&(leadList.get(i).next_action_date != null && !leadList.get(i).next_action_date.isEmpty()))
eventModel.addEvent(new DefaultScheduleEvent(""+leadList.get(i).next_action+" "+leadList.get(i).business_name + " - " +leadList.get(i).id, nextLeadActionDate(leadList.get(i).next_action_date), nextLeadActionDate(leadList.get(i).next_action_date)));
}
What I want to do is add the variable leadList.get(i).id to the call as the data object, if I add it to the end of this constructor it goes in as a Style Class.
Anyone see a easy way to get it in there?

Data needs to be an object. It has to be declared as an object before passing in.

Related

How to Fix the Following Error: Cannot invoke "String.length()" because "this.inputStr" is null

/* Returns the count of the user's character. */
public int getUserCharCount(){
inputStr = inputStr;
for (int i = 0; i < inputStr.length(); i++) {
if (inputStr.charAt(i) == userChar) {
userCharCount ++;
}
}
return userCharCount;
}
By default, inputStr is "" in the Main code. It should be updating to the user input.
You can log inputStr
maybe user set it to null.
also you may check if your variable is null before action.
It hard to say what wrong because you not provide class that hold your variable, and not provide way that class are created and modified.
may be you create new one with null, may be user change value to null

How to check Shipment lines before confirming?

I'm trying to cycle though the SOShipLines before confirming to validate the data. I've got the override to work, but can't seem to figure out how I move through the records. The error (which is set to always trip) always returns 0 lines. I'm pretty sure I need to be looking at the shiporder variable but don't know how.
public void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder, ConfirmShipmentDelegate baseMethod)
{
int TheCount = 0;
int TheLines = 0;
string TheTest = "";
SOShipLineExt TheSOLineExt = null;
foreach (SOShipLine line in Base.Transactions.Select())
{
TheLines += 1;
TheSOLineExt = PXCache<SOShipLine>.GetExtension<SOShipLineExt>(line);
TheTest += "-" + TheSOLineExt.UsrSpeedyShippedPieces;
if (TheSOLineExt.UsrSpeedyShippedPieces==null)
{
TheCount += 1;
}
//UpdateLineDirect(Base.Caches[typeof(SOLine)], line);
};
//}; if (TheCount > 0 )
throw new PXException("What the hell!!!" + Convert.ToString(TheCount) + "/" + Convert.ToString(TheLines));
baseMethod(docgraph,shiporder);
}
Thanks in advance.
-Travis
It looks like the problem is in an undefined current SOShipment record. Please look at Base.Transactions view - there is Current<SOShipment.shipmentNbr> definition there
public PXSelect<SOShipLine,
Where<SOShipLine.shipmentNbr, Equal<Current<SOShipment.shipmentNbr>>>,
OrderBy<Asc<SOShipLine.shipmentNbr, Asc<SOShipLine.sortOrder>>>> Transactions;
Then look at base ConfirmShipment method and you will see special code which sets current record equal to your SOShipment shiporder parameter
this.Clear();
Document.Current = Document.Search<SOShipment.shipmentNbr>(shiporder.ShipmentNbr);
I suppose that the current SOShipment record is skipping somewhere before the ConfirmShipment method - this why Base.Transactions.Select() returns nothing
There are 2 possible solutions from my standpoint:
Set current SOShipment record equal to your SOShipment shiporder parameter as it is done inside the base ConfirmShipment method
Base.Clear() // maybe this is a good idea to call the Clear method too
Document.Current = Document.Search<SOShipment.shipmentNbr>(shiporder.ShipmentNbr);
Or write your own BQL select with a required parameter instead of current
foreach (SOShipLine line in PXSelect<SOShipLine,
Where<SOShipLine.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>,
OrderBy<Asc<SOShipLine.shipmentNbr, Asc<SOShipLine.sortOrder>>>>
.Select(Base, shiporder.ShipmentNbr))
{
// do something here
}

Mapping umbraco node to strongtyped object

I am working with Umbraco 4.7.1 and I am trying to map the content-nodes to some autogenerated strong typed objects. I have tried using both valueinjecter and automapper, but OOTB neither of them map my properties. I guess it is because all properties on an Umbraco node (the cms document) are retrieved like this:
node.GetProperty("propertyName").Value;
And my strongly typed objects are in the format of MyObject.PropertyName. So how do I map the property on the node which is retrieved using a method and a string beginning with a lowercase character into a property on MyObject where the property begins with an uppercase character ?
UPDATE
I managed to create the following code which maps the umbraco node as intended, by digging around in the Umbraco sourcecode for some inspiration on how to cast string-properties to strongly typed properties:
public class UmbracoInjection : SmartConventionInjection
{
protected override bool Match(SmartConventionInfo c)
{
return c.SourceProp.Name == c.TargetProp.Name;
}
protected override void Inject(object source, object target)
{
if (source != null && target != null)
{
Node node = source as Node;
var props = target.GetProps();
var properties = node.Properties;
for (int i = 0; i < props.Count; i++)
{
var targetProperty = props[i];
var sourceProperty = properties[targetProperty.Name];
if (sourceProperty != null && !string.IsNullOrWhiteSpace(sourceProperty.Value))
{
var value = sourceProperty.Value;
var type = targetProperty.PropertyType;
if (targetProperty.PropertyType.IsValueType && targetProperty.PropertyType.GetGenericArguments().Length > 0 && typeof(Nullable<>).IsAssignableFrom(targetProperty.PropertyType.GetGenericTypeDefinition()))
{
type = type.GetGenericArguments()[0];
}
targetProperty.SetValue(target, Convert.ChangeType(value, type));
}
}
}
}
}
As you can see I use the SmartConventionInjection to speed things up.
It still takes approximately 20 seconds to map something like 16000 objects. Can this be done even faster ?
thanks
Thomas
with ValueInjecter you would do something like this:
public class Um : ValueInjection
{
protected override void Inject(object source, object target)
{
var node = target as Node;
var props = source.GetProps();
for (int i = 0; i < props.Count; i++)
{
var prop = props[i];
target.GetProperty(prop.Name).Value;
}
}
}

Watin: Iterating through text boxes in a telerik gridview

I am currently developing a testing framework for a web data entry application that is using the Telerik ASP.Net framework and have run into a blocker. If I step through my code in debug mode the test will find the text box that I am looking for and enter some test data and then save that data to the database. The problem that I am running into is that when I let the test run on it's own the test fails saying that it couldn't fine the column that was declared. Here is my code:
/*Method to enter test data into cell*/
private TableCell EditFieldCell(string columnHeader)
{
var columnIndex = ColumnIndex(columnHeader);
if (columnIndex == -1)
throw new InvalidOperationException(String.Format("Column {0} not found.", columnHeader));
return NewRecordRow.TableCells[columnIndex];
}
/*Method to return column index of column searching for*/
public int ColumnIndex(string columnHeader)
{
var rgTable = GridTable;
var rgCount = 0;
var rgIndex = -1;
foreach (var rgRow in rgTable.TableRows)
{
foreach (var rgElement in rgRow.Elements)
{
if (rgElement.Text != null)
{
if (rgElement.Text.Equals(columnHeader))
{
rgIndex = rgCount;
break;
}
}
rgCount++;
}
return rgIndex;
}
My thinking is that something with my nested for loops is presenting the problem because the rgIndex value that is returned when I let the program run is -1 which tells me that the code in the for loops isn't being run.
TIA,
Bill Youngman
Code that gets the table Column index. You need to pass the Table(verify that the table exists while debug):
public int GetColumnIndex(Table table, string headerName)
{
ElementCollection headerElements = table.TableRows[0].Elements; //First row contains the header
int counter = 0;
foreach (var header in headerElements)
{
if (header.ClassName != null && header.ClassName.Contains(headerName)) //In this case i use class name of the header you can use the text
{
return counter;
}
counter++;
}
// If not found
return -1;
}

cloning/copying a dojo data store

Hi can some one please tell me how to copy one data store to another in dojo. I tried it in following way but it doesn't work. Here I'm try to copy data from jsonStore to newGridStore.
jsonStore.fetch({query:{} , onComplete: onComplete});
var onComplete = function (items, request) {
newGridStore = null;
newGridStore = new dojo.data.ItemFileWriteStore({
data : {}
});
if (items && items.length > 0) {
var i;
for (i = 0; i < items.length; i++) {
var item = items[i];
var attributes = jsonStore.getAttributes(item);
if (attributes && attributes.length > 0) {
var j;
for (j = 0; j < attributes.length; j++) {
var newItem = {};
var values = jsonStore.getValues(item, attributes[j]);
if (values) {
if (values.length > 1) {
// Create a copy.
newItem[attributes[j]] = values.slice(0, values.length);
} else {
newItem[attributes[j]] = values[0];
}
}
}
newGridStore.newItem(newItem);
}
}
}
}
Based on the comments asked above. You are trying to copy values to a new Store for the single reason to be able to detect which values have changes and then save them individually, without having to send the entire store.
This approach is totally wrong.
Dojo has isDirty() and offers you the ability to revert() a store back to it's original values. It knows which values have changed and you don't need to do this.
Take a look at the bog standard IFWS here: http://docs.dojocampus.org/dojo/data/ItemFileWriteStore
Make sure you read everything from here: http://docs.dojocampus.org/dojo/data/ItemFileWriteStore#id8
What you want to do is create your own _saveCustom method which you will override your store with, and then when you save, you will be able to see which values have changed.
Click on the demo at the very bottom of the page. It shows you EXACTLY how do to it using _saveCustom

Resources