Pathfinder issue with nested MVCGrid & MVCForm and the solution - atk4

I am using a structure like this to support moving from upper level related tables down to lower level tables. In general the idea is to either edit a record in the current view or list the child records for that same view through the use of expander columns.
Structurally it is Customer -> Customer Products -> Product Details -> Product Activity.
Customer MVCgrid ok
edit MVCform (via expander column) ok
view products MVCgrid (via expander column) ok
edit a product MVCform pathfinder error
view products details MVCGrid pathfinder error
edit product details MVCform
view product activity MVCGrid
This structure works at the outer level. I can edit a customer record or view the customer products as expected. When I click on "edit a product" (MVCform) or "view product details" (MVCgrid) I am getting a pathfinder error:
PathFinder_Exception
Unable to include cvCustProducts\cvuidcontrol\cvuiddetails.php
"cvuiddetails" is function name declared as "function page_cvuiddetails()"
I've checked and rechecked everything I can think. It seems to me that the function name is not being made available and pathfinder is being invoked to find out where the page "cvuiddetails" is located and comes up empty.
Any suggestions will be greatly appreciated.
=====[SOLUTION]============================================
Ten minutes later.........
Aha!!!!
Here is the solution to the problem I just posted a few minutes ago and I hope everyone else finds this to be useful:
When nesting the functions, prefix the name of the function with the name of the invoking function
function page_cvuidcontrol() contains the expander column that invokes "cvuiddetails".
ORIGINAL FUNCTION NAME: function page_cvuiddetails()
NEW FUNCTION NAME: function page_cvuidcontrol_cvuiddetails()

If you have file page/cvuidcontrol.php you can define page_cvuiddetails() function in that file. This is called sub-pages.
http://agiletoolkit.org/blog/multi-page-pages-finally/
However, take care and make sure you don't name function the same as a class name. It's a very unfortunate coincidence and have gave me problems few times.
class page_details {
function page_details(){
}
}
This won't work, because PHP considers this function to be a constructor.

Related

Java FX database problem when adding new datas

I have a database problem. I want to create a simple Java FXML application which could help to my friend to search the protein/potassium content of the foods, because of kidney disease.
I have 4 class variables: name, protein, potassium, and id for the database (to identify the variables in the database).
I use Java DB - derby.
My application has 2 pane: 1. „home screen” has a textfield, where you have to type the name of the food you looking for, and if you click to the „search” button it will search the appropriate data from the database and show it in a table on the next pane. (the searching isn't working yet – you can type anything in the textfield what you want and then click to "Search", but no results showed yet in the table).
On the next page you can see the table, and at the bottom, you can add new data. I did a test to make sure the database works correctly, so the second pane I wrote a test Name, test Protein content, test Potassium content, and then click to the „add” button. Then the table shows just the potassium value, and puts this value in the first column instead of the „potassium column”. By the way, the db works but just stores the last value in the first column. I think I have a mistake somewhere in the setTableData method, but I run out of the ideas.
Here is my link to my files: https://github.com/Capkit/FirstProjects
I would be very grateful if somebody could help me!

How to get Background title in BDD Specflow C#

How do I get the name of the pre test condition "Background" tag in a Feature using Specflow + Nunit in C #?
I can get the name of the "Feature" like this:
return FeatureContext.Current.FeatureInfo.Title;
And the name of the "Scenario" like this:
return ScenarioContext.Current.ScenarioInfo.Title;
I also need to get the name of the "Background", or check if it exists.
Feature: FeatureTest
Description Feature...
Background: Get Background name or check it exists (Return It)
...Given, And
Scenario: Scenario Test
...Given, And
TL;DR
The reason you can't access the Background, is because the steps contained within it are duplicated at runtime across all of the scenarios within a feature, effectively removing the background.
The Answer:
Generally speaking, Backgrounds do not have a title:
Ability: Adding and Removing items from the basket
As a customer,
I want the ability to add and remove items from my basket
In order to choose the items that I want to purchase from the site
Background:
Given I have logged in as a customer
And I visit the "Clothing" page
Scenario: Adding items to my basket
When I add "Black Jeans" to my basket in size "M"
Then the total should be "£9.99"
Scenario: Removing items from the basket
Given I have added an item of clothing to my basket
When I empty my basket
Then the total should be "£0.00"
The Background steps get duplicated across the scenarios within the feature, meaning that the scenarios in my example are effectively:
Scenario: Adding items to my basket
Given I have logged in as a customer
And I visit the "Clothing" page
When I add "Black Jeans" to my basket in size "M"
Then the total should be "£9.99"
Scenario: Removing items from the basket
Given I have logged in as a customer
And I visit the "Clothing" page
Given I have added an item of clothing to my basket
When I empty my basket
Then the total should be "£0.00"
Why would you need to access the Background description, if what you're actually testing is covered by the Scenario description?
That is why currently they do not offer this as a feature. It's additional information within a file that allow ease of reading and understanding of what is actually being tested - but if your steps are descriptive enough, do you need a description for the setup for a test?
This information is currently not available at runtime in SpecFlow. Please open an issue on GitHub for this, that we can potentially add this in later versions.
But generally it is bad practice to depend on such fragile (potential often changing magic strings).
Better way would be to check for a tag on Scenario or Feature level.
Also be aware, that you don't know at runtime, that you are currently executing parts of the background. There is no difference between these Given steps and the Given steps of your scenario.

How do I create and save a set/array of objects for a given Core Data entity?

I have an app that will ideally compare luxury restaurants and their respective dishes against each other. This means I have a Core Data entity called Restaurant with attributes like restaurantName, location, averagePrice, and foodType. I have a second Core Data entity called MenuItem with attributes like foodName, caloryCount, price, and rating.
Since the goal is to compare, say, two steakhouses and their filet mignons on calories/price/rating, I'd really like to take a preloaded list of MenuItem objects I have (an array called selectedMenuItems) and somehow save that as an attribute of the Restaurant entity so that each individual restaurant will have an instance of those menu item objects attached to it (after which the user could edit the calories/price/rating for each menu item on a restaurant by restaurant basis). In the most ideal scenario, if anything was added or subtracted from the selectedMenuItems array of objects it would be reflected across all individual restaurants.
What I've tried so far:
1.) Many-to-many relationship between Restaurant and MenuItem
As you can probably guess from my above description, this didn't work out how I wanted it to since it only connected each restaurant to the selectedMenuItems array, and any alterations made in a restaurant propagated through the relationship to the array (this was a fundamental misunderstanding of relationships, on my part).
2.) Create an attribute of type Transformable in Restaurant to hold the selectedMenuItems array
This looked like it was going to work for a moment. As I said, I created an attribute called menuItems in my Restaurant entity of type Transformable, and then in the view controller for each restaurant's detail view (the view controller that displays the menuItems is an additional navigation step) I added the following inside of viewDidLoad():
// The selected Restaurant is passed from the prior screen to restaurant
restaurant.menuItems = selectedMenuItems as NSObject?
Which resulted in seemingly what I needed, except for the fact that if I made any changes to the selectedMenuItems array, it would cause the app to crash with the console readout 'NSInvalidArgumentException', reason: '-[Restaurant encodeWithCoder:]: unrecognized selector sent to instance.
3.) Break apart the selectedMenuItems array of objects into matched arrays of properties
After doing some experimenting with 2.), it appeared as though having an array of objects was the issue. Because of this, I iterated through selectedMenuItems and stripped out the properties into their own arrays (foodNameArray, caloryCountArray, priceArray, etc.). After that, I assigned each of those to newly created attributes of my Restaurant entity:
restaurant.foodNames = foodNameArray as NSObject?
restaurant.caloryCounts = caloryCountArray as NSObject?
restaurant.prices = priceArray as NSObject?
Now, this was already looking very dodgy and prone to catastrophic failure. It did, however, work pretty much how I wanted it to. The issue here was that any changes to selectedMenuItems (like adding/removing a new object) didn't pass through to my restaurants after the first load. This is in contrast with 1.) where the changes propagated from the restaurants to selectedMenuItems (bottom to top) compared to 3.), where I want the changes to flow top to bottom.
Given the above descriptions, does anyone have advice on how I can get the functionality I'm looking for?
Rather than a many-many relationship, I would use three entities:
Restaurant, as you currently have;
Dish, which represents the generic menu item, such as "Filet mignon" or "Rib-eye"; and
MenuItem, which is a particular Dish served by a particular Restaurant.
Because Dish is generic, it would have only one attribute foodName (though you might want others). MenuItem would have attributes caloryCount, price, rating.
Since each MenuItem represents a particular dish served by a particular restaurant, it would have "to-one" relationships to Restaurant and Dish. For each relationship, the inverse would be "to-many": a Restaurant will serve many MenuItems, and a Dish could feature in many MenuItems.
You can then preload the list of Dishes, from which users can select those which are served by a particular restaurant. You can then create corresponding MenuItems and can presumably let users record calories/price/rating. If the user deletes a MenuItem, the corresponding Dish is unaffected, so will be available for other existing and/or new Restaurants. If the user wants to add a MenuItem for which there is no existing Dish, you can add a new Dish, which will then be available for any subsequent MenuItems.

How to save child properties?

Breeze & Angular & MV*
I get an invoice object and expand it's necessary properties: Customer, Details, etc.
To access detail properties is easy, invoice.detail[n].property. And saving changes to existing properties (1 - n) is also easy. In my UI, I simply loop through my object vm.invoice.details to get & display all existing details, bind them to inputs, edit at will, call saveChanges(), done!
(keep in mind, in this UI, I need to complete the following too....)
Now, I have blank inputs for a new detail I need to insert.
However, I need to insert a new detail into the existing array of invoice details.
For example: invoice #5 has 3 details (detail[0], detail[1], detail[2]). I need to insert into this existing invoice, detail[3], and call saveChanges()
I've tried to call the manger.createEntity('invoice') but it complains about FK constraints. I know you can pass values as a second argument in createEntity('obj', newvalues)...but is that the correct and only method?
Seems like this should all be much easier but, well, I am at a loss so, please help where you can. TIA!
Take a look at the DocCode sample which has tests for all kinds of scenarios including this one.
Perhaps the following provides the insight you're looking for:
function addNewDetail() {
var newDetail = manager.createEntity('Detail', {
invoice: vm.currentInvoice,
... other initial values
});
// the newDetail will show up automatically if the view is bound to vm.details
}
Notice that I'm initializing the parent invoice navigation property. Alternatively, I could just set the Detail entity's FK property inside the initializer:
...
invoiceId: vm.currentInvoice.id,
...
Either way, Breeze will add the new detail to the details collection of the currentInvoice.
Your question spoke in terms of inserting the new Detail. There is no need to insert the new Detail manually and you can't manage the sort order of the vm.currentInvoice.details property any way.
Breeze has no notion of sort order for collection navigation properties.
If you need to display the details in a particular order you could add a sorting filter to your angular binding to vm.currentInvoice.details.
Make sure you have correct EntityName, because sometimes creating entity is a not as simple as it seems.Before working with entities see
http://www.getbreezenow.com/documentation/creating-entities
I will suggest you to look ur metadata file, go to last line of your file, you can see the field named "entitySet"
"entitySet":{"name":"Entity_Name","entityType":"Self.Entity_Name"}
check the entityName here i took as "Entity_Name" and then try to create the entity and use this name
manger.createEntity('Entity_Name');

ZK window not unique in ID space

In our project we use ZK for webpages. There is a combobox which has lists. When selected, it fetches data from a java object through onSelect, i have given the logic.
when i select one there are 4 listboxes on that page to be filled with data according to the selection. when i select first time, no problem occurs.
But on second time i get an error pop-up like "Not Unique in the id space of Window" and showing the list box item id which have to be filled on select.
Can any one help out there?
Note: Though it shows this error i get the listboxes filled correctly according to the combo box selection. Still i cant stop this error occurring..
Your issue is a conflict of ids in ZK's id space.
A bit of background..
ZK generates ids for components at runtime, if you open up the DOM in the browser you'll see each component has some machine readable id.
However, you can also give components an id. This id does not go to the DOM but lets you reference the component in your application.
These two shouldn't be confused. The conflict you're experiencing is with the latter type of id; you are assigning a component an id in your Java code or in your ZUL file which, at runtime, is not unique.
The case you describe where it only happens the second time you click is a tell tale sign here. The content you are adding on the event has an id defined in it and you are not removing this content when you are done.
Consider the following example:
#Wire
private Window myWindow;
#Listen(Events.ON_CLICK + " = #myButton")
public void onMyButtonClicked() {
Label myLabel = new Label("sean is cool");
myLabel.setId("myLabel");
myLabel.setParent(myWindow);
}
This will work the first time you click myButton, but will throw your error on the second click. That is because the second event tries to add myLabel to myWindow but there is already a myLabel there.
There are lots of ways to resolve this depending on what you are trying to do.
Have a look through the ZK documentation on ID Spaces for more.
I also faced the same error.
My scenario is the same, only the widgets being used are different.
Hence putting my workaround here.
I have put the following piece of code in the doBeforeCompose() method of the composer:
Component widgetWithId = page.getFellowIfAny("widgetWithId");
if (widgetWithId != null) {
widgetWithId.detach();
}
Here widgetWithId is the component/widget, which is tried to be regenerated by the code, with the same Id and ZK is throwing error for it.

Resources