Nested tool-bar button in xul - firefox-addon

I am having a toolbar-button with type "menu-button". Can I have two toolbar-buttons inside this one?

Since you would like to have a button inside a menu-button, here you go. But, this is not a pretty good UI.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<window id="main-window">
<toolbox id="navigator-toolbox">
<toolbar id="xulschoolhello-toolbar" toolbarname="xulschoolhello.toolbarName.label;"
customizable="true" mode="icons" context="toolbar-context-menu"
defaultset="xulschoolhello-hello-world-button"
insertbefore="PersonalToolbar" />
<hbox>
<row> <button flex="1" type="menu" label="Menu">
<menupopup>
<menuitem label="Option 1" oncommand="setText('menu-text','Option 1');" />
<menuitem label="Option 2" oncommand="setText('menu-text','Option 2');" />
<menuitem label="Option 3" oncommand="setText('menu-text','Option 3');" />
<menuitem label="Option 4" oncommand="setText('menu-text','Option 4');" />
</menupopup>
</button> </row>
<row> <button flex="1" type="menu-button" label="MenuButton" oncommand="alert('Button was pressed!');">
<menupopup>
<menuitem label="Option A" oncommand="setText('menu-text','Option A');" />
<menuitem label="Option B" oncommand="setText('menu-text','Option B');" />
<menuitem label="Option C" oncommand="setText('menu-text','Option C');" />
<menuitem label="Option D" oncommand="setText('menu-text','Option D');" />
</menupopup>
</button></row>
</hbox>
<hbox pack="center">
<description id="menu-text" value="Testing" />
</hbox>
</toolbox>
</window>
</window>

Related

Binding Item data to the Detail View

This is my View Page
SecondView.view.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form" xmlns:anubhav="myfiori.controls" xmlns:html="http://www.w3.org/1999/xhtml" controllerName="myfiori.controller.SecondView">
<Page title="My Second View" showNavButton="true" navButtonPress="onBack" content="{/ZPO_HEADERSet}">
<content>
<Table id="lineItemsList" width="auto" items="{toItems}">
<headerToolbar>
<Toolbar id="lineItemsToolbar">
<Title id="lineItemsHeader" />
</Toolbar>
</headerToolbar>
<columns>
<Column>
<Text text="Doc No" />
</Column>
<Column >
<Text text="Material No"/>
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
<Text text="{Ebelp}"/>
<Text text="{Matnr}"/>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
My Item data path is "ZPO_HEADERSet('1100000001’)".so that I will get all the Items for the particular Header Id.
My controller
SecondView.controller.js
sPath = "/ZPO_HEADERSet('" + Id + "')";
this.getView().bindElement(sPath);
On pressing the Master Row, I should get it's items. But I'm getting all Item rows of every Header Id as shown in below screenshot.
This is because in your Page you are binding the whole entity set to the content aggregation.
Delete this content="{/ZPO_HEADERSet}" and try again.
The bindElement(sPath) function will prefix all your relative bindings with the 'sPath'

Why destructor of an extended binding is not called when extending binding is removed?

Creating a XulRunner application for Windows I found that if binding B extends binding A. And B is being removed, then only destructor of B is called, not followed by a call of A's destructor.
Is there something wrong with my code, or this is a XulRunner bug (I haven't find matching bug in bugzilla)?
Here is an example that I tested on XulRunner 23 and 35:
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<!--<binding-a id="A" style="-moz-binding: url('binding.xml#binding-a')"/>-->
<binding-b id="B" style="-moz-binding: url('binding.xml#binding-b')"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
binding.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("A.destructor");
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
window.print("B.destructor");
]]></destructor>
</implementation>
</binding>
</bindings>
here is the solution for your problem:
bindings.xml:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="binding-a">
<content>
<xul:label anonid="label" value="Binding A"/>
</content>
<implementation>
<constructor><![CDATA[
var label = document.getAnonymousElementByAttribute(this, "anonid", "label");
label.value = label.value + " A.constructor";
window.print("A.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="f">
<body><![CDATA[
window.print("A.f");
]]></body>
</method>
<method name="destruct">
<body><![CDATA[
window.print("A.destructor");
]]></body>
</method>
</implementation>
</binding>
<binding id="binding-b" extends="#binding-a">
<content>
<xul:label anonid="label" value="Binding B"/>
</content>
<implementation>
<constructor><![CDATA[
window.print("B.constructor");
]]></constructor>
<destructor><![CDATA[
this.destruct();
]]></destructor>
<method name="destruct">
<body><![CDATA[
this.__proto__.__proto__.destruct.call(this);
window.print("B.destructor");
]]></body>
</method>
</implementation>
</binding>
</bindings>
bindings.css:
#namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
binding-a { -moz-binding: url("bindings.xml#binding-a"); }
binding-b { -moz-binding: url("bindings.xml#binding-b"); }
main.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="bindings.css" type="text/css"?>
<window id="main" title="My App" width="500" height="300" sizemode="normal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script><![CDATA[
function print(aString) {
document.getElementById("log_msg").value += aString + "\n";
}
function removeElementById(aId) {
document.getElementById(aId).remove();
};
function callF(aId) {
document.getElementById(aId).f();
}
]]></script>
<vbox flex="1">
<label onclick="removeElementById('A')">remove A</label>
<label onclick="removeElementById('B')">remove B</label>
<label onclick="callF('A')">Call A.f()</label>
<label onclick="callF('B')">Call B.f()</label>
<binding-a id="A"/>
<binding-b id="B"/>
<textbox id="log_msg" label="Text" placeholder="placeholder" multiline="true" rows="6"/>
</vbox>
</window>
I know that it is a hack in fact but it works.

How do I get an attribute using the 'amazon-ecs' gem?

I am using Amazon Product Advertising API (amazon-ecs) gem, but I am using the item_lookup method instead of item_search, which is the only one documented.
I am looking to return the item TradeInValue but I am confused as to how to do that. It is clearly being returned, but I am not sure how to parse it.
This is the call:
Amazon::Ecs.item_lookup('9780521153348', :response_group => 'ItemAttributes', :id_type => 'ISBN', :search_index => 'Books')
And this is the return, which I am not sure what to do with. The methods in amazon-ecs don't seem to work for item_lookup and XPath isn't working either:
#<Amazon::Ecs::Response:0x007ff3325250d0 #doc=#<Nokogiri::XML::Document:0x3ff9992927a0 name="document" children=[#<Nokogiri::XML::Element:0x3ff997067414 name="ItemLookupResponse" children=[#<Nokogiri::XML::Element:0x3ff99706b924 name="OperationRequest" children=[#<Nokogiri::XML::Element:0x3ff99706b474 name="HTTPHeaders" children=[#<Nokogiri::XML::Element:0x3ff99706f470 name="Header" attributes=[#<Nokogiri::XML::Attr:0x3ff99706f0ec name="Name" value="UserAgent">, #<Nokogiri::XML::Attr:0x3ff99706f074 name="Value" value="Ruby">]>]>, #<Nokogiri::XML::Element:0x3ff9970760cc name="RequestId" children=[#<Nokogiri::XML::Text:0x3ff999296468 "053626d3-e3cd-47d2-bc8b-7ac6a0c5f6d2">]>, #<Nokogiri::XML::Element:0x3ff99929f6f8 name="Arguments" children=[#<Nokogiri::XML::Element:0x3ff9992a3bb8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992a3960 name="Name" value="Operation">, #<Nokogiri::XML::Attr:0x3ff9992a3938 name="Value" value="ItemLookup">]>, #<Nokogiri::XML::Element:0x3ff9992a73f8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992a7204 name="Name" value="Signature">, #<Nokogiri::XML::Attr:0x3ff9992a7010 name="Value" value="IMd3D0DGgAcaLR6XcuObzdAgFbOya7mbIRtZFbNijVA=">]>, #<Nokogiri::XML::Element:0x3ff9992ab41c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992ab2dc name="Name" value="AssociateTag">, #<Nokogiri::XML::Attr:0x3ff9992ab2c8 name="Value" value="textscom-20">]>, #<Nokogiri::XML::Element:0x3ff9992af774 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992af6ac name="Name" value="ItemId">, #<Nokogiri::XML::Attr:0x3ff9992af698 name="Value" value="9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9992b0c3c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b0b4c name="Name" value="IdType">, #<Nokogiri::XML::Attr:0x3ff9992b0b10 name="Value" value="ISBN">]>, #<Nokogiri::XML::Element:0x3ff9992b7794 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b7578 name="Name" value="AWSAccessKeyId">, #<Nokogiri::XML::Attr:0x3ff9992b7550 name="Value" value="AKIAJLOCEGWTFXZKXLEQ">]>, #<Nokogiri::XML::Element:0x3ff9992b2244 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992b208c name="Name" value="Timestamp">, #<Nokogiri::XML::Attr:0x3ff9992b2064 name="Value" value="2013-05-07T17:46:35Z">]>, #<Nokogiri::XML::Element:0x3ff9992bffc0 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992bff20 name="Name" value="ResponseGroup">, #<Nokogiri::XML::Attr:0x3ff9992bff0c name="Value" value="ItemAttributes">]>, #<Nokogiri::XML::Element:0x3ff9992be1e8 name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992c38c8 name="Name" value="SearchIndex">, #<Nokogiri::XML::Attr:0x3ff9992c3a30 name="Value" value="Books">]>, #<Nokogiri::XML::Element:0x3ff9992ca95c name="Argument" attributes=[#<Nokogiri::XML::Attr:0x3ff9992ca344 name="Name" value="Service">, #<Nokogiri::XML::Attr:0x3ff9992ca2a4 name="Value" value="AWSECommerceService">]>]>, #<Nokogiri::XML::Element:0x3ff9992d3d7c name="RequestProcessingTime" children=[#<Nokogiri::XML::Text:0x3ff9992d382c "0.0289960000000000">]>]>, #<Nokogiri::XML::Element:0x3ff9992d7eb8 name="Items" children=[#<Nokogiri::XML::Element:0x3ff9992d7148 name="Request" children=[#<Nokogiri::XML::Element:0x3ff9992d6900 name="IsValid" children=[#<Nokogiri::XML::Text:0x3ff9992dae10 "True">]>, #<Nokogiri::XML::Element:0x3ff9992da758 name="ItemLookupRequest" children=[#<Nokogiri::XML::Element:0x3ff9992df884 name="IdType" children=[#<Nokogiri::XML::Text:0x3ff9992df014 "ISBN">]>, #<Nokogiri::XML::Element:0x3ff9992de678 name="ItemId" children=[#<Nokogiri::XML::Text:0x3ff9992e2e1c "9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9983a5580 name="ResponseGroup" children=[#<Nokogiri::XML::Text:0x3ff9983a59b8 "ItemAttributes">]>, #<Nokogiri::XML::Element:0x3ff9983a510c name="SearchIndex" children=[#<Nokogiri::XML::Text:0x3ff9983a43c4 "Books">]>, #<Nokogiri::XML::Element:0x3ff9983a925c name="VariationPage" children=[#<Nokogiri::XML::Text:0x3ff9983a8d0c "All">]>]>]>, #<Nokogiri::XML::Element:0x3ff9983a8244 name="Item" children=[#<Nokogiri::XML::Element:0x3ff9983add70 name="ASIN" children=[#<Nokogiri::XML::Text:0x3ff9983ad6f4 "0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983acc04 name="DetailPageURL" children=[#<Nokogiri::XML::Text:0x3ff9983ac4d4 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983b1768 name="ItemLinks" children=[#<Nokogiri::XML::Element:0x3ff9983b1024 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b0a20 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b028c "Technical Details">]>, #<Nokogiri::XML::Element:0x3ff9983b5b60 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b5638 "http://www.amazon.com/Turgot-Progress-Sociology-Economics-Philosophical/dp/tech-data/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983b5034 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b4a58 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b46d4 "Add To Baby Registry">]>, #<Nokogiri::XML::Element:0x3ff9983b406c name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b9ad0 "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983b95d0 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983b9080 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983b8cd4 "Add To Wedding Registry">]>, #<Nokogiri::XML::Element:0x3ff9983b8a2c name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983b834c "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983bcff0 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983bc49c name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983bc0f0 "Add To Wishlist">]>, #<Nokogiri::XML::Element:0x3ff9983c1b40 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983c158c "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0521153344%26SubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983c01dc name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983c5da8 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983c595c "Tell A Friend">]>, #<Nokogiri::XML::Element:0x3ff9983c5358 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983c4674 "http://www.amazon.com/gp/pdp/taf/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983c9750 name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983c8828 name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983cc888 "All Customer Reviews">]>, #<Nokogiri::XML::Element:0x3ff9983d1f18 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983d19c8 "http://www.amazon.com/review/product/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>, #<Nokogiri::XML::Element:0x3ff9983d152c name="ItemLink" children=[#<Nokogiri::XML::Element:0x3ff9983d107c name="Description" children=[#<Nokogiri::XML::Text:0x3ff9983d02d0 "All Offers">]>, #<Nokogiri::XML::Element:0x3ff9983d5730 name="URL" children=[#<Nokogiri::XML::Text:0x3ff9983d4e48 "http://www.amazon.com/gp/offer-listing/0521153344%3FSubscriptionId%3DAKIAJLOCEGWTFXZKXLEQ%26tag%3Dtextscom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0521153344">]>]>]>, #<Nokogiri::XML::Element:0x3ff9983dd00c name="ItemAttributes" children=[#<Nokogiri::XML::Element:0x3ff9983dc33c name="Author" children=[#<Nokogiri::XML::Text:0x3ff9983e1364 "Ronald L. Meek">]>, #<Nokogiri::XML::Element:0x3ff9983e0af4 name="Binding" children=[#<Nokogiri::XML::Text:0x3ff9983e04a0 "Paperback">]>, #<Nokogiri::XML::Element:0x3ff9983e0068 name="EAN" children=[#<Nokogiri::XML::Text:0x3ff9983e5c34 "9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9983e5270 name="EANList" children=[#<Nokogiri::XML::Element:0x3ff9983e4424 name="EANListElement" children=[#<Nokogiri::XML::Text:0x3ff9983d7c60 "9780521153348">]>]>, #<Nokogiri::XML::Element:0x3ff9983d7724 name="ISBN" children=[#<Nokogiri::XML::Text:0x3ff9983d7120 "0521153344">]>, #<Nokogiri::XML::Element:0x3ff9983d6cc0 name="IsEligibleForTradeIn" children=[#<Nokogiri::XML::Text:0x3ff9983d6130 "1">]>, #<Nokogiri::XML::Element:0x3ff9983d99c0 name="ItemDimensions" children=[#<Nokogiri::XML::Element:0x3ff9983d963c name="Height" attributes=[#<Nokogiri::XML::Attr:0x3ff9983d959c name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983d83cc "902">]>, #<Nokogiri::XML::Element:0x3ff9983ed7a4 name="Length" attributes=[#<Nokogiri::XML::Attr:0x3ff9983ed448 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983f3244 "598">]>, #<Nokogiri::XML::Element:0x3ff9983f290c name="Weight" attributes=[#<Nokogiri::XML::Attr:0x3ff9983f26f0 name="Units" value="hundredths-pounds">] children=[#<Nokogiri::XML::Text:0x3ff9983e93c0 "64">]>, #<Nokogiri::XML::Element:0x3ff9983e8f38 name="Width" attributes=[#<Nokogiri::XML::Attr:0x3ff9983e8e34 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff9983efa2c "43">]>]>, #<Nokogiri::XML::Element:0x3ff9983ef144 name="Label" children=[#<Nokogiri::XML::Text:0x3ff9983eecbc "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9983ee988 name="Languages" children=[#<Nokogiri::XML::Element:0x3ff9983ee410 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a80009c name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a801a14 "English">]>, #<Nokogiri::XML::Element:0x3ff99a8010f0 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a800948 "Unknown">]>]>, #<Nokogiri::XML::Element:0x3ff99a800574 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a8002b8 name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a80419c "English">]>, #<Nokogiri::XML::Element:0x3ff99a805484 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a804b10 "Original Language">]>]>, #<Nokogiri::XML::Element:0x3ff99a804070 name="Language" children=[#<Nokogiri::XML::Element:0x3ff99a808d64 name="Name" children=[#<Nokogiri::XML::Text:0x3ff99a80d6d4 "English">]>, #<Nokogiri::XML::Element:0x3ff99a80c680 name="Type" children=[#<Nokogiri::XML::Text:0x3ff99a8110a4 "Published">]>]>]>, #<Nokogiri::XML::Element:0x3ff99a8157a8 name="ListPrice" children=[#<Nokogiri::XML::Element:0x3ff99a8142cc name="Amount" children=[#<Nokogiri::XML::Text:0x3ff99a819358 "2899">]>, #<Nokogiri::XML::Element:0x3ff99a818d04 name="CurrencyCode" children=[#<Nokogiri::XML::Text:0x3ff99a818764 "USD">]>, #<Nokogiri::XML::Element:0x3ff99a81c8a0 name="FormattedPrice" children=[#<Nokogiri::XML::Text:0x3ff99a81d534 "$28.99">]>]>, #<Nokogiri::XML::Element:0x3ff99a81ccb0 name="Manufacturer" children=[#<Nokogiri::XML::Text:0x3ff99a81c648 "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff99a81c2d8 name="NumberOfItems" children=[#<Nokogiri::XML::Text:0x3ff99a821cec "1">]>, #<Nokogiri::XML::Element:0x3ff99a821580 name="NumberOfPages" children=[#<Nokogiri::XML::Text:0x3ff99a82043c "194">]>, #<Nokogiri::XML::Element:0x3ff99a825bbc name="PackageDimensions" children=[#<Nokogiri::XML::Element:0x3ff99a824cd0 name="Height" attributes=[#<Nokogiri::XML::Attr:0x3ff99a824b68 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff99a824168 "63">]>, #<Nokogiri::XML::Element:0x3ff99a829d98 name="Length" attributes=[#<Nokogiri::XML::Attr:0x3ff99a829d20 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff99a828eac "890">]>, #<Nokogiri::XML::Element:0x3ff99a828c68 name="Weight" attributes=[#<Nokogiri::XML::Attr:0x3ff99a828b8c name="Units" value="hundredths-pounds">] children=[#<Nokogiri::XML::Text:0x3ff99a828074 "66">]>, #<Nokogiri::XML::Element:0x3ff9983f69d0 name="Width" attributes=[#<Nokogiri::XML::Attr:0x3ff9983f68f4 name="Units" value="hundredths-inches">] children=[#<Nokogiri::XML::Text:0x3ff997c6340c "598">]>]>, #<Nokogiri::XML::Element:0x3ff997c62cf0 name="ProductGroup" children=[#<Nokogiri::XML::Text:0x3ff997c623b8 "Book">]>, #<Nokogiri::XML::Element:0x3ff9961e1d2c name="ProductTypeName" children=[#<Nokogiri::XML::Text:0x3ff9961e0e40 "ABIS_BOOK">]>, #<Nokogiri::XML::Element:0x3ff9961e0508 name="PublicationDate" children=[#<Nokogiri::XML::Text:0x3ff9961e7b28 "2010-06-10">]>, #<Nokogiri::XML::Element:0x3ff9961e75c4 name="Publisher" children=[#<Nokogiri::XML::Text:0x3ff9961e727c "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9961e70b0 name="SKU" children=[#<Nokogiri::XML::Text:0x3ff9961e6bc4 "Y9780521153348">]>, #<Nokogiri::XML::Element:0x3ff9961e682c name="Studio" children=[#<Nokogiri::XML::Text:0x3ff9961ebc64 "Cambridge University Press">]>, #<Nokogiri::XML::Element:0x3ff9961ea120 name="Title" children=[#<Nokogiri::XML::Text:0x3ff996f67ac8 "Turgot on Progress, Sociology and Economics: A Philosophical Review of the Successive Advances of the Human Mind on Universal History Reflections on ... in the History and Theory of Politics)">]>, #<Nokogiri::XML::Element:0x3ff996f676cc name="TradeInValue" children=[#<Nokogiri::XML::Element:0x3ff996f67028 name="Amount" children=[#<Nokogiri::XML::Text:0x3ff996f66ca4 "310">]>, #<Nokogiri::XML::Element:0x3ff996f669d4 name="CurrencyCode" children=[#<Nokogiri::XML::Text:0x3ff996f663a8 "USD">]>, #<Nokogiri::XML::Element:0x3ff996fadbb8 name="FormattedPrice" children=[#<Nokogiri::XML::Text:0x3ff996fad014 "$3.10">]>]>]>]>]>]>]>>
Okay, I figured it out. I was trying to treat item_lookup as a single return value, rather than a hash the way search is returned.
item_lookup is basically the same as item_search:
res = Amazon::Ecs.item_lookup('9780521153348', :response_group => 'ItemAttributes', :id_type => 'ISBN', :search_index => 'Books')
res.items.each do |item|
puts item.get('ItemAttributes/TradeInValue/FormattedPrice')
end

render composite component based on a Boolean condition

I developed a composite JSF 2 component, and it is working pretty well.
In one of the pages where I use my custom component, it is necessary that composite component should be rendered according to a boolean condition.
Pretty Much similar as the rendered attribute works in JSF standard components.
So I tried to implement it like this:
<cc:interface componentType="ciudadComponent">
<cc:attribute name="paises" type="java.util.List" required="true" />
<cc:attribute name="departamentos" type="java.util.List" required="true" />
<cc:attribute name="ciudades" type="java.util.List" required="true" />
<cc:attribute name="name" type="java.lang.String" required="true" />
<cc:attribute name="value" type="org.colfuturo.model.to.CiudadTO" required="true"## Heading ## />
<cc:attribute name="etiquetaPais" type="java.lang.String" />
<cc:attribute name="etiquetaBotonOK" type="java.lang.String" />
<cc:attribute name="etiquetaBotonCancelar" type="java.lang.String" />
<cc:attribute name="etiquetaDepartamento" type="java.lang.String" />
<cc:attribute name="etiquetaCiudad" type="java.lang.String" />
<cc:attribute name="styleClass" type="java.lang.String" />
<cc:attribute name="backGroundColor" type="java.lang.String" default="#b0c4de" />
<cc:attribute name="rendered" type="java.lang.Boolean" required="false" default="true" />
</cc:interface>
<cc:implementation>
<h:inputText id="seleccionado" binding="#{cc.seleccionado}" disabled="true" rendered="#{cc.rendered}">
<f:converter converterId="CiudadConverter" />
</h:inputText>
</cc:implementation>
In the page where I insert the composite component, it is like this:
<gambatte:ciudad
paises="#{menuTreeBean.listaPaises}"
departamentos="#{menuTreeBean.listaDepartamentos}"
ciudades="#{menuTreeBean.listaCiudades}" styleClass="mySelectStyle"
etiquetaBotonOK="#{msg['perfil.common.btnOK']}" etiquetaBotonCancelar="#{msg['perfil.common.btnCancelar']}"
etiquetaPais="#{msg['perfil.common.lblPais']}"
etiquetaDepartamento="#{msg['perfil.common.lblDepartamento']}"
etiquetaCiudad="#{msg['perfil.common.lblCiudad']}" name="otraSedeCiudad"
value="#{EstudiosRealizadosBean.otraSedeCiudad}"
rendered="#{EstudiosRealizadosBean.showOtraSede()}" />
The method EstudiosRealizadosBean.showOtraSede() returns java.lang.Boolean.
I get the following Exception when rendering the page:
java.lang.IllegalArgumentException: rendered
How can I solve this ?
I have also tried to put a boolean condition, but the same exception is raised
I am posting my whole component code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface componentType="ciudadComponent">
<cc:attribute name="paises" type="java.util.List" required="true" />
<cc:attribute name="departamentos" type="java.util.List" required="true" />
<cc:attribute name="ciudades" type="java.util.List" required="true" />
<cc:attribute name="name" type="java.lang.String" required="true" />
<cc:attribute name="value" type="org.colfuturo.model.to.CiudadTO" required="true" />
<cc:attribute name="etiquetaPais" type="java.lang.String" />
<cc:attribute name="etiquetaBotonOK" type="java.lang.String" />
<cc:attribute name="etiquetaBotonCancelar" type="java.lang.String" />
<cc:attribute name="etiquetaDepartamento" type="java.lang.String" />
<cc:attribute name="etiquetaCiudad" type="java.lang.String" />
<cc:attribute name="styleClass" type="java.lang.String" />
<cc:attribute name="backGroundColor" type="java.lang.String" default="#b0c4de" />
<cc:attribute name="cacheInterface" type="org.colfuturo.business.interfaces.IServicioCache" required="false" />
</cc:interface>
<cc:implementation>
<span id="#{cc.clientId}" style="white-space:nowrap">
<h:inputText id="seleccionado" binding="#{cc.seleccionado}" disabled="true" >
<f:converter converterId="CiudadConverter" />
</h:inputText>
<a4j:commandButton execute="#none" immediate="true" value=".." oncomplete="document.getElementById('#{cc.attrs.name}').style.position = 'absolute'; document.getElementById('#{cc.attrs.name}').style.display = 'inline-block';" />
<br />
<ui:fragment>
<div id="#{cc.attrs.name}" layout="block" style="border-radius: 10px; background-color:#{cc.attrs.backGroundColor}; display:none;" >
<table border="0">
<tr>
<td><h:outputText value="#{cc.attrs.etiquetaPais}" /></td>
<td>
<rich:select id="pais" binding="#{cc.pais}" styleClass="#{cc.attrs.styleClass}" defaultLabel="Seleccione un País" >
<f:selectItems value="#{cc.listaPaises}" />
<f:ajax event="selectitem" execute="#this" listener="#{cc.updatePais}" />
</rich:select>
</td>
</tr>
<tr>
<td><h:outputText value="#{cc.attrs.etiquetaDepartamento}" /></td>
<td>
<rich:select id="departamento" binding="#{cc.departamento}" styleClass="#{cc.attrs.styleClass}" defaultLabel="Seleccione un Departamento" >
<f:selectItems value="#{cc.listaDepartamentos}" />
<f:ajax event="selectitem" execute="#this" listener="#{cc.updateDepartamento}" />
</rich:select>
<a4j:outputPanel layout="block" binding="#{cc.panelOtroDepartamento}" >
<h:inputText id="otroDepartamento" binding="#{cc.otroDepartamento}" >
<f:ajax event="keyup" listener="#{cc.enableSubmit}" execute="#this otraCiudad" />
</h:inputText>
</a4j:outputPanel>
</td>
</tr>
<tr>
<td><h:outputText value="#{cc.attrs.etiquetaCiudad}" /></td>
<td>
<rich:select id="ciudad" binding="#{cc.ciudad}" styleClass="#{cc.attrs.styleClass}" defaultLabel="Seleccione una Ciudad" >
<f:selectItems value="#{cc.listaCiudades}" />
<f:ajax event="selectitem" execute="#this" listener="#{cc.updateCiudad}" />
</rich:select>
<a4j:outputPanel layout="block" binding="#{cc.panelOtraCiudad}" >
<h:inputText id="otraCiudad" binding="#{cc.otraCiudad}" >
<f:ajax event="keyup" listener="#{cc.enableSubmit}" execute="#this otroDepartamento" />
</h:inputText>
</a4j:outputPanel>
</td>
</tr>
<tr>
<td>
<h:commandButton value="#{cc.attrs.etiquetaBotonOK}" disabled="true" binding="#{cc.botonAcccion}" onclick="document.getElementById('#{cc.attrs.name}').style.position = 'absolute'; document.getElementById('#{cc.attrs.name}').style.display = 'none';" >
<f:ajax execute="ciudad" listener="#{cc.submit}" />
</h:commandButton>
</td>
<td>
<a4j:commandButton value="#{cc.attrs.etiquetaBotonCancelar}" execute="#none" immediate="true" oncomplete="document.getElementById('#{cc.attrs.name}').style.position = 'absolute'; document.getElementById('#{cc.attrs.name}').style.display = 'none';" />
</td>
</tr>
</table>
</div>
</ui:fragment>
<div style="display:block;" ></div>
</span>
</cc:implementation>
</html>
Get rid of <cc:attribute name="rendered">.
It's already defined in UIComponent class, which <cc:implementation> extends from. You don't need to redefine it. The same story applies to id and binding attributes, by the way.
You also don't need to re-apply rendered="#{cc.rendered}" on the composite component's first child. You can also just get rid of it. The <my:composite rendered> already applies on the whole composite component itself.

<prefwindow> sizing itself to the wrong tab when browser.preferences.animateFadeIn == true

I've run into (yet another) bug with the preferences screen of my extension. When browser.preferences.animateFadeIn is set to true (as it is on Mac), the window size should change to fit the content exactly on switching panes. Instead it is sized to the largest pane when the window is opened, but it changes by as much as it should when switching panes. If that's not too clear, here is a screencast: http://files.droplr.com/files/22337488/4IVT.ScreenFlow.mov
Even after removing all <script> elements, and most of the panes, the error still happens:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
<?xml-stylesheet href="chrome://nextplease/skin/nextpleasePreferences.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://nextplease/locale/nextplease.dtd">
<prefwindow id="nextpleaseprefs" title="&options.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="nextplease.images" label="&options.images.title;" image="chrome://nextplease/skin/Image.png">
<preferences>
<preference id="nextimages" name="nextplease.nextimage.expr0" type="unichar"/>
<preference id="previmages" name="nextplease.previmage.expr0" type="unichar"/>
<preference id="firstimages" name="nextplease.firstimage.expr0" type="unichar"/>
<preference id="lastimages" name="nextplease.lastimage.expr0" type="unichar"/>
</preferences>
<hbox flex="1">
<listbox width="80" onselect="nextplease.selectedPanelChanged(this);">
<listitem label="&options.next;" selected="true"/>
<listitem label="&options.prev;"/>
<listitem label="&options.first;"/>
<listitem label="&options.last;"/>
</listbox>
<separator class="groove" orient="vertical" style="opacity: 0.5; margin-top: 5px; margin-bottom: 5px;"/>
<vbox flex="1">
<deck flex="1">
<listbox id="Next_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="Prev_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="First_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
<listbox id="Last_Image_list" seltype="multiple" flex="1"
onkeypress="nextplease.removeSelectedOnDelete(event, this);" onselect="nextplease.enableDisableRemoveButton(this);" onchange="nextplease.syncListboxToPref(this);"/>
</deck>
<hbox id="images_dummy_texts" collapsed="true">
<textbox id="Next_Image_dummy_text" preference="nextimages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="Prev_Image_dummy_text" preference="previmages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="First_Image_dummy_text" preference="firstimages" onchange="nextplease.syncPrefToListbox(this);"/>
<textbox id="Last_Image_dummy_text" preference="lastimages" onchange="nextplease.syncPrefToListbox(this);"/>
</hbox>
<separator class="thin"/>
<hbox align="stretch">
<textbox type="text" maxlength="256" onkeypress="nextplease.addOnReturn(event, this);"/>
<button label="&options.add;" style="margin-left: 0"
oncommand="nextplease.addToListbox(this);"/>
<spacer flex="1" minwidth="15"/>
<button label="&options.removeSelected;" disabled="true" style="margin-right: 2px"
oncommand="nextplease.removeSelectedFromListbox(this);"/>
<spacer flex="1" minwidth="40"/>
<button label="&options.restoreDefault;"
oncommand="nextplease.restoreDefaultListbox(this);"/>
</hbox>
</vbox>
</hbox>
</prefpane>
<prefpane id="nextplease.debug" label="&options.debug.title;" image="chrome://nextplease/skin/Settings.png">
<preferences>
<preference id="log" name="nextplease.log" type="bool"/>
<preference id="log.detailed" name="nextplease.log.detailed" type="bool"/>
<preference id="log.file" name="nextplease.log.file" type="bool"/>
<preference id="highlight" name="nextplease.highlight" type="bool"/>
<preference id="highlight.color" name="nextplease.highlight.color" type="string"/>
<preference id="highlight.prefetched" name="nextplease.highlight.prefetched" type="bool"/>
<preference id="highlight.prefetched.color" name="nextplease.highlight.prefetched.color" type="string"/>
</preferences>
<vbox>
<checkbox label="&options.log.normal;" preference="log"/>
<checkbox label="&options.log.detailed;" preference="log.detailed"/>
<!--<checkbox id="nextplease.log.file" label="&options.log.file;" preference="log.file/>-->
<separator/>
<hbox>
<checkbox label="&options.highlight;"
preference="highlight"
oncommand="nextplease.enableDisableHighlightColorPickers();"/>
<colorpicker type="button" preference="highlight.color"/>
</hbox>
<hbox>
<checkbox label="&options.highlight.prefetched;"
preference="highlight.prefetched"
oncommand="nextplease.enableDisableHighlightColorPickers();"/>
<colorpicker type="button" preference="highlight.prefetched.color"/>
</hbox>
</vbox>
</prefpane>
</prefwindow>
Yes, I'd agree that it's a bug. When the first pane loads, the prefwindow sizes itself to its content. In your case, this includes several "background" panes. Unfortunately the code to detect this gets bypassed in the animating case. The current code looks something like this:
if (animation) {
if (switching)
animate();
} else {
if (panes > 1)
fixHeight();
}
It should instead look something like this:
if (animation && switching)
animate();
else if (panes > 1)
fixHeight();
This would fix the height of the first pane even when animation was enabled. (If there is only one pane then there is nothing to do of course.)

Resources