I'm trying to mix motion-layout and Teacup in a RubyMotion project. I've created an example view helper to illustrate my problem:
module Teacup::Layout
def example(name, options = {})
subview UIView, name do
subview UILabel, "#{name}_label".to_sym, text: options[:label]
auto do
horizontal "|-[#{name}_label]-|"
end
end
end
end
When I call example(:example), text: "Test" inside a layout block, my code throws the following exception:
(main)> 2013-10-25 13:40:45.989 rui[55552:80b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format:
example_label is not a key in the views dictionary.
H:|-[example_label]-|
If I omit the motion-layout code and inspect the views, the example_label view is a child of the example view. What's going on here?
In the documentation for Teacup, it says:
# if you need to apply these to a different view, or if you want to assign
# different names to use in the ASCII strings
# auto(layout_view=self.view, layout_subviews={}, &layout_block)
Due to the 'dynamic' nature of the creation of all these views, and the layout (motion-layout) being in a subview instead of a layout (teacup), it just might be getting confused, though subview and layout are similar.
Anyway, try being very specific about which views are going into the auto block using the suggestion from the documentation, then there can be no ambiguity about what should be in the layout.
Related
I am using HoloViews version 1.12.0 . I am attempting to create a layout that contains two DynamicMaps, but I am getting the error:
WARNING:param.Warning: Layout contains HoloMaps which are not nested in the recommended format for accessing your data; calling .collate() on these objects will resolve any violations of the recommended nesting presented in the Composing Data tutorial ...
One of the DynamicMaps itself contains a layout that consists of a Radial Heat Map, and a Div. The other DynamicMap contains a Table object. The idea is to add some additional DynamicMaps to the layout, such that there are streams creating click through parent child relationship between the DynamicMaps.
I have run the .collate() function on both of the DynamicMaps, but it didn't return any output, and the error persists.
If I alter the one DynamicMap that contains the layout of the div and radial heat map, to just containing the one object or the other, the issue goes away.
Here is the data structures output for my layout.
:Layout
.DynamicMap.I :DynamicMap [ownership,survey_type,rep,approval,timeframe,nps_type]
.DynamicMap.II :DynamicMap [ownership,survey_type,rep,approval,timeframe,nps_type]
The http://holoviews.org/user_guide/Building_Composite_Objects.html user guide explains the order things need to be nested to work smoothly without collate:
A DynamicMap normally takes the same spot as a HoloMap in such a hierarchy.
I'm surprised that .collate() "didn't return any output", though; I don't think there is any version of .collate() in HoloViews that doesn't return something, so there's presumably some other problem.
I am pretty new to Flex.
What I am trying to achieve is to have two different layouts and initialize them based on the user's choice. Each of these layouts is defined in its own mxml component.
I have two components:
and
I could add both in the beginning and have only one visible but I don't want to go down that road. What I tried so far is to have an event handler that replaces the current instance but I hit a wall. Let's say that LeftAligned is the component initialized first and then I want to change it with RightAligned. Now:
If I try to replace the lement based on its id: newElement:RightAligned = new RightAligned(); LayoutArea = newElement; I get a implicit coercion error that it can't convert RightAligned to LeftAligned.
If I try to removeElement(LayoutArea); addElement(newElement); then I get an exception thrown from other parts of the application that call LayoutArea's methods (event based).
What solutions are there for this? Thank you
I'm trying to get a list of parent items that a RepositoryLocalObject (e.g. Component) is inherited from. So if I have a pub ID 1 with component tcm:1-80 and a child pub ID 2, then this component is shared in the child pub as tcm:2-80. So I want to get tcm:2-80's parent, or anything that's in the tree moving up.
I've tried the GetBluePrintChain() method on a local copy of a component where it works fine. However, on shared component it returns an InvalidActionException: "This item is shared". The documentation mentions that this exception is thrown on shared items. But how does this make sense? Obviously if any item that has a blueprint chain beyond itself would be shared (or be a local copy). So to me it doesn't make sense to have this method throw an exception on something that has a blueprint chain. It seems contradictory.
My question is somewhat related to Getting root publication of component, but it is different. I need to understand why this exception is thrown on shared items. Can someone please explain and perhaps share a use case to support it?
As far as I know the GetBluePrintChain methods are meant to look down a BluePrint when you're standing at the top of it. So in your case, you should get the item in its owning publication context and then invoke GetBluePrintChain.
Item item = package.GetByName("Component");
Component component = new Component(item.GetAsXmlDocument().DocumentElement,
engine.GetSession());
TcmUri id = TemplateUtilities.CreateTcmUriForPublication(
component.OwningRepository.Id.ItemId, component.Id);
var blueprintchain = ((Component)engine.GetObject(id)).GetBluePrintChain();
package.PushItem(package.CreateStringItem(ContentType.Text,
blueprintchain.ToString()));
package.PushItem(package.CreateStringItem(ContentType.Text,
""+System.Linq.Enumerable.Count(blueprintchain)));
foreach (var item in blueprintchain)
{
package.PushItem(package.CreateTridionItem(ContentType.Component, item));
}
I just ran the above C# fragment as a TBB in two scenarios:
in a child publication on a shared Component
in a child publication on a localized Component
In case 1 the blueprintchain will contain a single item: the shared Component. In case 2 the blueprintchain will contain two items: the shared Component and the localized Component.
To summarize the answer above, here's a practical work-around for "Item is shared" issue:
Calling GetBluePrintChain() for an arbitrary item that happens to be shared will fail:
return
item.GetBluePrintChain(
new BluePrintChainFilter(
BluePrintChainDirection.Up,
engine.GetSession()
)
).LastOrDefault();
The solution is to find a top-most localized item's parent first as per Frank's recipe:
return
((RepositoryLocalObject)engine
.GetObject(
TemplateUtilities.CreateTcmUriForPublication(
item.OwningRepository.Id.ItemId,
item.Id
)
)
).GetBluePrintChain(
new BluePrintChainFilter(
BluePrintChainDirection.Up,
engine.GetSession()
)
).LastOrDefault();
i tried to use Meteor.renderList to render some sort of chat messages. I use the Template.foo.rendered callback method to add the domFragment to a list.
Template.foo.rendered = ->
list = this.find "ul"
list.appendChild fragmet
If I place the list inside <template name="foo"> Meteor throws errors in an endless loop/recursion.
Uncaught Error: LiveRange start and end must have a parent
I have to use another template thats not directly connected to foo. Appending the list from within the foo#rendered callback than works as expected.
Template.foo.rendered = ->
document.getElementById("foo").appendChild fragmet # element with id foo not part of template foo
I think, that there is a problem with the reactive contextes used by the template and renderList? Anyone knows if this is a bug or the expected behavior? I looked into the sources but was lost in there quite fast ;)
Thanks!
This makes sense because you are appending an element to the template when the template is rendered. So, every time the template is rendered, it appends an element to itself, causing it to re-render itself, ad infinitum.
Are you sure you want Meteor.renderList to render your list rather than using an {{each}} iterator in the template itself?
I have a flex4 applciation (mx+spark). When I use:
FlexGlobals.topLevelApplication.styleManager.loadStyleDeclarations(skinName, true);
This works fine: new style is applied.
The trouble is when I apply a new style, it mixes both: this happens because I need to Unload style first.
I try to unload it with:
FlexGlobals.topLevelApplication.styleManager.unloadStyleDeclarations("style/normal.swf",false);
And I always got an error:
ReferenceError: Error #1069: La property 0 cannot be found on Number
and there is no default value.
at normal/unloadOverrides()[null/normal-generated.as:721]
at normal/unload()[null/normal-generated.as:676]
Any idea on how to load/unload swf css in Flex4?
The styles will be updated the next time one of the following methods is called with the update property set to true:
clearStyleDeclaration()
loadStyleDeclarations()
setStyleDeclaration()
unloadStyleDeclarations()
Typically, if you call the one of these methods multiple times, you set this property to true only on the last call, so that Flex does not call the styleChanged() method multiple times.
More information here.