Widget doesn't show in Panel - uibinder

I'm using gxt 3.0.1 and gwt 2.5.1.
I’ve created FramedPanel and Widget with UiBinder and it works fine. Widget inherits from Composite. After adding Widget to FramedPanel it doesn't show up.
Before:
After:
Main View:
<ui:with type="com.sencha.gxt.core.client.util.Margins" field="centerMargins">
<ui:attributes top="4" right="4" bottom="0" left="4" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.MarginData" field="centerData">
<ui:attributes margins="{centerMargins}" />
</ui:with>
<ui:with type="com.sencha.gxt.core.client.util.Margins" field="middleMargins">
<ui:attributes top="5" right="0" bottom="5" left="0" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="middleData">
<ui:attributes margins="{middleMargins}" width="1" height="-1" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="eastData">
<ui:attributes minSize="200" maxSize="1000" size="400" margins="{eastMargins}" collapsible="true" split="true" />
</ui:with>
<ui:with type="com.sencha.gxt.core.client.util.Margins" field="eastMargins">
<ui:attributes top="0" right="1" bottom="0" left="5" />
</ui:with>
<core:FramedPanel headerVisible="false">
<c:BorderLayoutContainer borders="false">
<c:center layoutData="{centerData}">
<c:VerticalLayoutContainer ui:field="mainVerContainer">
<c:child layoutData="{middleData}">
<p:PanView />
</c:child>
</c:VerticalLayoutContainer>
</c:center>
<c:east layoutData="{eastData}">
<core:ContentPanel headingText="" />
</c:east>
</c:BorderLayoutContainer>
</core:FramedPanel>
Widget's View:
<ui:with type="com.sencha.gxt.widget.core.client.grid.ColumnModel" field="columnModel" />
<ui:with type="com.sencha.gxt.data.shared.ListStore" field="store" />
<ui:with type="com.sencha.gxt.widget.core.client.grid.GridView" field="view">
<ui:attributes stripeRows="true" columnLines="true" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.MarginData" field="centerData">
<ui:attributes margins="{centerMargins}" />
</ui:with>
<ui:with type="com.sencha.gxt.core.client.util.Margins" field="centerMargins">
<ui:attributes top="0" right="0" bottom="0" left="0" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="topData">
<ui:attributes width="1" height="30" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData" field="middleData">
<ui:attributes width="1" height="1" />
</ui:with>
<ui:with type="com.sencha.gxt.core.client.util.Margins" field="southMargins">
<ui:attributes top="1" right="1" bottom="5" left="1" />
</ui:with>
<ui:with type="com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData" field="southData">
<ui:attributes size=".5f" minSize="200" maxSize="1000" margins="{southMargins}" collapsible="true" split="true" />
</ui:with>
<core:ContentPanel headerVisible="false" ui:field="mainPanel" borders="false">
<c:BorderLayoutContainer borders="false">
<c:center layoutData="{centerData}">
<core:ContentPanel headingText="Grid" collapsible="false" ui:field="documentPanel">
<c:VerticalLayoutContainer borders="false">
<c:child layoutData="{topData}">
<t:ToolBar ui:field="topToolBar">
<b:TextButton ui:field="toPreviousPackageButton" toolTip="Up" />
<t:SeparatorToolItem />
</t:ToolBar>
</c:child>
<c:child layoutData="{middleData}">
<grid:Grid cm="{columnModel}" store="{store}" view="{view}" loadMask="true" columnReordering="true" borders="false" />
</c:child>
</c:VerticalLayoutContainer>
</core:ContentPanel>
</c:center>
<c:south layoutData="{southData}">
<core:ContentPanel ui:field="propertiesPanel" headingText="Properties" />
</c:south>
</c:BorderLayoutContainer>
</core:ContentPanel>

Related

phonegap app using handlebars.js (list view) not registering touch on iOS

i am building an app using phonegap, handlebars.js (for templating). I have a js list where i iterate though to show information of each element of the list using handlebars.js templates. there is a click event registered for each element of the list.
######### javascript code #####################
$('body').on('click', 'div.payment_tab', function(event) {
event.preventDefault();
if(self.allowclick==1) {
document.location=$(this).attr("data-target");
return false;
} else {
console.log("else for clicking the payment tab. allowclick is not 1");
return false;
}
});
$('body').on('click' , 'div.payment-checkbox', function(event) {
event.preventDefault();
$(this).toggleClass('checked');
$(this).toggleClass('unchecked');
$(this).parent().find('.invoice_amount').toggleClass('added');
$(this).parent().find('.invoice_amount').toggleClass('notadded');
var amounts = $('div.payment-amount-status .added');
var total = 0.00;
amounts.each(function(key,value) {
if($(value).text() != "") {
total += parseFloat($(value).text());
}
});
$('#amount_to_pay').text(total.toFixed(2));
});
######swipe event javascript######
$("#invoicesView").swipe( {
swipeStatus:function(event, phase, direction, distance, duration, fingers)
{
if (phase=="start")
{
app.allowclick=0;
}
if (phase=="cancel")
{
app.allowclick=1;
}
},
swipeDown:function(event, direction, distance, duration)
{
//Only Let swipe, if the Element is at the very top of the scroll
if($("#invoicesView .contentholder").scrollTop()<=40 && distance>40 )
{
app.allowclick=0;
app.get_payment_details();
}
},
swipeRight:function(event, direction, distance, duration)
{
},
swipeLeft:function(event, direction, distance, duration)
{
},
threshold:50,
cancelThreshold:50,
allowPageScroll:"vertical"
});
###### part of the main.html (handlebars.js template)############################
<script id="invoices-li-tpl" type="text/x-handlebars-template">
{{#.}}
<li>
<div class="payment-checkbox checked"></div>
<div class="payment_tab" data-target="#invoices/{{{this.payment_id}}}">
<div class='payment_info'>
<p>ORDER #:
<span class="invoice-info-order">{{this.order_num}}</span>
</p>
<p>PO:
{{#if this.customer_po}}
<span class="invoice-info-po">{{this.customer_po}}</span></p>
{{else}}
<span class="invoice-info-po">N/A</span>
{{/if}}
<p>DATE:
<span class="invoice-info-date">{{this.createdtime}}</span>
</p>
</div>
<div class='payment-amount-status {{this.paid}}'>
<p><span class ='invoice-amount-label'>TOTAL:</span>$<span class='invoice_amount added'>{{this.amount}}</span></p>
<p><span class ='invoice-status-label'>STATUS:</span><span>{{this.paid}}</span></p>
<p class='payment_id'>{{this.payment_id}}</p>
</div>
<div class='clearfix'></div>
</div>
</li>
{{/.}}
</script>
In the bundled app, the click event works fine on android but does not work on iOS (version 10,tested on iphone 6+). Even the checkbox click(div.payment-checkbox) is not registered on ios. Below is the config.xml i am using for the app. note that we have a similar list view in the app where the click event works on ios.
######## config.xml #########################
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="xxx" id="xxxxxxx" ios-CFBundleVersion="3.0.1" version="3.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" >
<name>xxxxx</name>
<description>
xxxxxx
</description>
<author email="xxx#xxxxx.com" href="xxxxxx">
xxxxxxxx
</author>
<content src="index.html" />
<preference name="deployment-target" value="7.0" />
<preference name="permissions" value="none" />
<preference name="orientation" value="portrait" />
<preference name="target-device" value="handset" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="false" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="cordova-plugin-console" source="npm" />
<gap:plugin name="cordova-plugin-device" source="npm" />
<gap:plugin name="cordova-plugin-dialogs" source="npm" />
<gap:plugin name="cordova-plugin-splashscreen" source="npm" />
<gap:plugin name="cordova-plugin-inappbrowser" source="npm" />
<gap:plugin name="cordova-plugin-customurlscheme" source="npm">
<param name="URL_SCHEME" value="xxxxx" />
</gap:plugin>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
<param name="onload" value="true" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<feature name="Device">
<param name="android-package" value="org.apache.cordova.device.Device" />
</feature>
<icon src="icon.png" />
<icon src="res/icon/android/ldpi.png" gap:platform="android" gap:qualifier="ldpi" />
<icon src="res/icon/android/mdpi.png" gap:platform="android" gap:qualifier="mdpi" />
<icon src="res/icon/android/hdpi.png" gap:platform="android" gap:qualifier="hdpi" />
<icon src="res/icon/android/xhdpi.png" gap:platform="android" gap:qualifier="xhdpi" />
<icon src="res/icon/android/xxhdpi.png" gap:platform="android" gap:qualifier="xxhdpi" />
<!-- iPhone / iPod Touch -->
<icon src="res/icon/ios/icon-60.png" gap:platform="ios" width="60" height="60" />
<icon src="res/icon/ios/icon-60#2x.png" gap:platform="ios" width="120" height="120" />
<icon src="res/icon/ios/icon-60#3x.png" gap:platform="ios" width="180" height="180" />
<!-- iPad -->
<icon src="res/icon/ios/icon-76.png" gap:platform="ios" width="76" height="76" />
<icon src="res/icon/ios/icon-76#2x.png" gap:platform="ios" width="152" height="152" />
<!-- Settings Icon -->
<icon src="res/icon/ios/icon-small.png" gap:platform="ios" width="29" height="29" />
<icon src="res/icon/ios/icon-small#2x.png" gap:platform="ios" width="58" height="58" />
<!-- Spotlight Icon -->
<icon src="res/icon/ios/icon-40.png" gap:platform="ios" width="40" height="40" />
<icon src="res/icon/ios/icon-40#2x.png" gap:platform="ios" width="80" height="80" />
<!-- iPhone / iPod Touch -->
<icon src="res/icon/ios/icon.png" gap:platform="ios" width="57" height="57" />
<icon src="res/icon/ios/icon#2x.png" gap:platform="ios" width="114" height="114" />
<!-- iPad -->
<icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="res/icon/ios/icon-72#2x.png" gap:platform="ios" width="144" height="144" />
<!-- iPad Spotlight and Settings Icon -->
<icon src="res/icon/ios/icon-50.png" gap:platform="ios" width="50" height="50" />
<icon src="res/icon/ios/icon-50#2x.png" gap:platform="ios" width="100" height="100" />
<gap:splash src="splash.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="www/res/screen/android/android_ldpi_portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="www/res/screen/android/android_mdpi_portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="www/res/screen/android/android_hdpi_portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="www/res/screen/android/android_xhdpi_portrait.png" />
<gap:splash gap:platform="blackberry" src="www/res/screen/blackberry/screen-225.png" />
<gap:splash src="res/screen/ios/Default.png" gap:platform="ios" width="320" height="480" />
<gap:splash src="res/screen/ios/Default#2x.png" gap:platform="ios" width="640" height="960" />
<gap:splash src="res/screen/ios/screen/ios/Default#3x.png" gap:platform="ios" width="960" height="1440" />
<!-- iPhone 5 / iPod Touch (5th Generation) -->
<gap:splash src="res/screen/ios/Default-568h#2x.png" gap:platform="ios" width="640" height="1136" />
<!-- iPad -->
<gap:splash src="res/screen/ios/Default-portrait-ipad.png" gap:platform="ios" width="768" height="1024" />
<gap:splash src="res/screen/ios/Default-landscape-ipad.png" gap:platform="ios" width="1024" height="768" />
<!-- Retina iPad -->
<gap:splash src="res/screen/ios/Default-Portrait#2x.png" gap:platform="ios" width="1536" height="2048" />
<gap:splash src="res/screen/ios/Default-Landscape#2x.png" gap:platform="ios" width="2048" height="1536" />
<gap:splash gap:platform="winphone" src="www/res/screen/windows-phone/screen-portrait.jpg" />
<platform name="ios">
<gap:plugin name="phonegap-plugin-push" spec="1.5.3" source="npm">
<params>
<param name="SENDER_ID" value="xxxxxxxx" />
</params>
</gap:plugin>
</platform>
<platform name="android">
<gap:plugin name="phonegap-plugin-push" spec="1.7.2" source="npm">
<params>
<param name="SENDER_ID" value="xxxxxxx" />
</params>
</gap:plugin>
</platform>
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<access origin="*" />
<access origin="http://*" />
<access origin="https://*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="5000" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="AutoHideSplashScreen" value="true" />
<access origin="*"/>
</widget>

PhoneGap Cordova YoutubeVideoPlayer Plugin An error this could be due to network issue of YouTube protocols

I create a "Play Youtube" App with PhoneGap(version 6.3.0) , Cordova (version 6.3.1) , simple load a youtube video by ID.
use Cordova YoutubeVideoPlayer plugin, using build.phonegap.com to build project, but not working with error:
An error occurred during the retrieval of the video. This could be due to network issue of YouTube protocols. Please try again later.
I test on android OS version 6.0.
Thanks in advance.
add to config.xml:
<plugin name="com.bunkerpalace.cordova.youtubevideoplayer" spec="1.0.1" source="pgb" />
Load youtube video when device ready in index.js
YoutubeVideoPlayer.openVideo('1s96mq8kfzY');
index.js
var app = {
initialize: function() {
this.bindEvents();
}, bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
}, onDeviceReady: function() {
app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
YoutubeVideoPlayer.openVideo('1s96mq8kfzY');
}
};
index.html
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>PhoneGap</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.hd.yu" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>YTube2</name>
<description>
Hello World sample application that responds to the deviceready event.
</description>
<author email="support#phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<plugin name="com.bunkerpalace.cordova.youtubevideoplayer" spec="1.0.1" source="pgb" />
<icon src="icon.png" />
<platform name="android">
<icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />
<icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />
<icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />
</platform>
<platform name="ios">
<icon height="57" platform="ios" src="www/res/icon/ios/icon.png" width="57" />
<icon height="114" platform="ios" src="www/res/icon/ios/icon#2x.png" width="114" />
<icon height="40" platform="ios" src="www/res/icon/ios/icon-40.png" width="40" />
<icon height="80" platform="ios" src="www/res/icon/ios/icon-40#2x.png" width="80" />
<icon height="50" platform="ios" src="www/res/icon/ios/icon-50.png" width="50" />
<icon height="100" platform="ios" src="www/res/icon/ios/icon-50#2x.png" width="100" />
<icon height="60" platform="ios" src="www/res/icon/ios/icon-60.png" width="60" />
<icon height="120" platform="ios" src="www/res/icon/ios/icon-60#2x.png" width="120" />
<icon height="180" platform="ios" src="www/res/icon/ios/icon-60#3x.png" width="180" />
<icon height="72" platform="ios" src="www/res/icon/ios/icon-72.png" width="72" />
<icon height="144" platform="ios" src="www/res/icon/ios/icon-72#2x.png" width="144" />
<icon height="76" platform="ios" src="www/res/icon/ios/icon-76.png" width="76" />
<icon height="152" platform="ios" src="www/res/icon/ios/icon-76#2x.png" width="152" />
<icon height="29" platform="ios" src="www/res/icon/ios/icon-small.png" width="29" />
<icon height="58" platform="ios" src="www/res/icon/ios/icon-small#2x.png" width="58" />
<icon height="87" platform="ios" src="www/res/icon/ios/icon-small#3x.png" width="87" />
<splash height="1136" platform="ios" src="www/res/screen/ios/Default-568h#2x~iphone.png" width="640" />
<splash height="1334" platform="ios" src="www/res/screen/ios/Default-667h.png" width="750" />
<splash height="2208" platform="ios" src="www/res/screen/ios/Default-736h.png" width="1242" />
<splash height="1242" platform="ios" src="www/res/screen/ios/Default-Landscape-736h.png" width="2208" />
<splash height="1536" platform="ios" src="www/res/screen/ios/Default-Landscape#2x~ipad.png" width="2048" />
<splash height="768" platform="ios" src="www/res/screen/ios/Default-Landscape~ipad.png" width="1024" />
<splash height="2048" platform="ios" src="www/res/screen/ios/Default-Portrait#2x~ipad.png" width="1536" />
<splash height="1024" platform="ios" src="www/res/screen/ios/Default-Portrait~ipad.png" width="768" />
<splash height="960" platform="ios" src="www/res/screen/ios/Default#2x~iphone.png" width="640" />
<splash height="480" platform="ios" src="www/res/screen/ios/Default~iphone.png" width="320" />
</platform>
<platform name="wp8">
<icon height="99" platform="wp8" src="www/res/icon/wp8/ApplicationIcon.png" width="99" />
<icon height="159" platform="wp8" src="www/res/icon/wp8/Background.png" width="159" />
<splash height="1280" platform="wp8" src="www/res/screen/wp8/screen-portrait.jpg" width="768" />
</platform>
<platform name="windows">
<icon height="150" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-100.png" width="150" />
<icon height="30" platform="windows" src="www/res/icon/windows/Square30x30Logo.scale-100.png" width="30" />
<icon height="50" platform="windows" src="www/res/icon/windows/StoreLogo.scale-100.png" width="50" />
<splash height="300" platform="windows" src="www/res/screen/windows/SplashScreen.scale-100.png" width="620" />
<icon height="120" platform="windows" src="www/res/icon/windows/StoreLogo.scale-240.png" width="120" />
<icon height="44" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-100.png" width="44" />
<icon height="106" platform="windows" src="www/res/icon/windows/Square44x44Logo.scale-240.png" width="106" />
<icon height="70" platform="windows" src="www/res/icon/windows/Square70x70Logo.scale-100.png" width="70" />
<icon height="71" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-100.png" width="71" />
<icon height="170" platform="windows" src="www/res/icon/windows/Square71x71Logo.scale-240.png" width="170" />
<icon height="360" platform="windows" src="www/res/icon/windows/Square150x150Logo.scale-240.png" width="360" />
<icon height="310" platform="windows" src="www/res/icon/windows/Square310x310Logo.scale-100.png" width="310" />
<icon height="150" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-100.png" width="310" />
<icon height="360" platform="windows" src="www/res/icon/windows/Wide310x150Logo.scale-240.png" width="744" />
<splash height="1920" platform="windows" src="www/res/screen/windows/SplashScreenPhone.scale-240.png" width="1152" />
</platform>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~5.2.2" />
</widget>

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.)

Add child to existing parent record in entity framework

My relationship between the parent and child is that they are connected by an edge. It is similiar to a directed graph structure.
DAL:
public void SaveResource(Resource resource)
{
context.AddToResources(resource); //Should also add children.
context.SaveChanges();
}
public Resource GetResource(int resourceId)
{
var resource = (from r in context.Resources
.Include("ToEdges").Include("FromEdges")
where r.ResourceId == resourceId
select r).SingleOrDefault();
return resource;
}
Service:
public void AddChildResource(int parentResourceId, Resource childResource)
{
Resource parentResource = repository.GetResource(parentResourceId);
ResourceEdge inEdge = new ResourceEdge();
inEdge.ToResource = childResource;
parentResource.ToEdges.Add(inEdge);
repository.SaveResource(parentResource);
}
Error: An object with the same key already exists in the ObjectStateManager. The existing object is in the Unchanged state. An object can only be added to the ObjectStateManager again if it is in the added state.
Image:
I have been told this is the sequence in submitting a child to an already existing parent:
Get parent -> Attach Child to parent -> submit parent.
That is the sequence I used. The code above is extracted from an ASP.NET MVC 2 application using the repository pattern.
EDMX file:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="XDbModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="XDbModelStoreContainer">
<EntitySet Name="Bundles" EntityType="XDbModel.Store.Bundles" store:Type="Tables" Schema="dbo" />
<EntitySet Name="CellProviders" EntityType="XDbModel.Store.CellProviders" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Comments" EntityType="XDbModel.Store.Comments" store:Type="Tables" Schema="dbo" />
<EntitySet Name="LocationPoints" EntityType="XDbModel.Store.LocationPoints" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Locations" EntityType="XDbModel.Store.Locations" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Offers" EntityType="XDbModel.Store.Offers" store:Type="Tables" Schema="dbo" />
<EntitySet Name="PostBundleJunction" EntityType="XDbModel.Store.PostBundleJunction" store:Type="Tables" Schema="dbo" />
<EntitySet Name="PostMedia" EntityType="XDbModel.Store.PostMedia" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Posts" EntityType="XDbModel.Store.Posts" store:Type="Tables" Schema="dbo" />
<EntitySet Name="ResourceEdges" EntityType="XDbModel.Store.ResourceEdges" store:Type="Tables" Schema="dbo" />
<EntitySet Name="ResourceNames" EntityType="XDbModel.Store.ResourceNames" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Resources" EntityType="XDbModel.Store.Resources" store:Type="Tables" Schema="dbo" />
<EntitySet Name="sysdiagrams" EntityType="XDbModel.Store.sysdiagrams" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Users" EntityType="XDbModel.Store.Users" store:Type="Tables" Schema="dbo" />
<EntitySet Name="Votes" EntityType="XDbModel.Store.Votes" store:Type="Tables" Schema="dbo" />
<AssociationSet Name="FK_Comments_Offers" Association="XDbModel.Store.FK_Comments_Offers">
<End Role="Offers" EntitySet="Offers" />
<End Role="Comments" EntitySet="Comments" />
</AssociationSet>
<AssociationSet Name="FK_Comments_Users" Association="XDbModel.Store.FK_Comments_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Comments" EntitySet="Comments" />
</AssociationSet>
<AssociationSet Name="FK_LocationPoints_Locations" Association="XDbModel.Store.FK_LocationPoints_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="LocationPoints" EntitySet="LocationPoints" />
</AssociationSet>
<AssociationSet Name="FK_PostBundleJunction_Bundles" Association="XDbModel.Store.FK_PostBundleJunction_Bundles">
<End Role="Bundles" EntitySet="Bundles" />
<End Role="PostBundleJunction" EntitySet="PostBundleJunction" />
</AssociationSet>
<AssociationSet Name="FK_PostBundleJunction_Posts" Association="XDbModel.Store.FK_PostBundleJunction_Posts">
<End Role="Posts" EntitySet="Posts" />
<End Role="PostBundleJunction" EntitySet="PostBundleJunction" />
</AssociationSet>
<AssociationSet Name="FK_Posts_Locations" Association="XDbModel.Store.FK_Posts_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_Posts_ResourceNames" Association="XDbModel.Store.FK_Posts_ResourceNames">
<End Role="ResourceNames" EntitySet="ResourceNames" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_Posts_Users" Association="XDbModel.Store.FK_Posts_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_ResourceEdges_Resources" Association="XDbModel.Store.FK_ResourceEdges_Resources">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceEdges" EntitySet="ResourceEdges" />
</AssociationSet>
<AssociationSet Name="FK_ResourceEdges_Resources1" Association="XDbModel.Store.FK_ResourceEdges_Resources1">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceEdges" EntitySet="ResourceEdges" />
</AssociationSet>
<AssociationSet Name="FK_ResourceNames_Resources" Association="XDbModel.Store.FK_ResourceNames_Resources">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceNames" EntitySet="ResourceNames" />
</AssociationSet>
<AssociationSet Name="FK_Users_Locations" Association="XDbModel.Store.FK_Users_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="Users" EntitySet="Users" />
</AssociationSet>
<AssociationSet Name="FK_Votes_Posts" Association="XDbModel.Store.FK_Votes_Posts">
<End Role="Posts" EntitySet="Posts" />
<End Role="Votes" EntitySet="Votes" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Bundles">
<Key>
<PropertyRef Name="BundleId" />
</Key>
<Property Name="BundleId" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="CellProviders">
<Key>
<PropertyRef Name="CellProviderID" />
</Key>
<Property Name="CellProviderID" Type="uniqueidentifier" Nullable="false" />
</EntityType>
<EntityType Name="Comments">
<Key>
<PropertyRef Name="CommentID" />
</Key>
<Property Name="CommentID" Type="uniqueidentifier" Nullable="false" />
<Property Name="ParentPostID" Type="uniqueidentifier" />
<Property Name="OfferPostID" Type="uniqueidentifier" />
<Property Name="UserID" Type="uniqueidentifier" Nullable="false" />
</EntityType>
<EntityType Name="LocationPoints">
<Key>
<PropertyRef Name="LocationPointId" />
</Key>
<Property Name="LocationPointId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Latitude" Type="float" Nullable="false" />
<Property Name="Longitude" Type="float" Nullable="false" />
<Property Name="Altitude" Type="float" Nullable="false" />
<Property Name="Count" Type="int" Nullable="false" />
<Property Name="LocationId" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="Locations">
<Key>
<PropertyRef Name="LocationId" />
</Key>
<Property Name="LocationId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Address1" Type="nvarchar" Nullable="false" MaxLength="200" />
<Property Name="Address2" Type="nvarchar" MaxLength="200" />
<Property Name="Address3" Type="nvarchar" MaxLength="200" />
<Property Name="State" Type="nvarchar" Nullable="false" MaxLength="200" />
<Property Name="Country" Type="nvarchar" Nullable="false" MaxLength="200" />
</EntityType>
<EntityType Name="Offers">
<Key>
<PropertyRef Name="OfferID" />
</Key>
<Property Name="OfferID" Type="uniqueidentifier" Nullable="false" />
<Property Name="NeedOffer" Type="uniqueidentifier" Nullable="false" />
<Property Name="ProvisionOffer" Type="uniqueidentifier" Nullable="false" />
</EntityType>
<EntityType Name="PostBundleJunction">
<Key>
<PropertyRef Name="BundleId" />
<PropertyRef Name="PostId" />
</Key>
<Property Name="BundleId" Type="int" Nullable="false" />
<Property Name="PostId" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="PostMedia">
<Key>
<PropertyRef Name="MediaId" />
</Key>
<Property Name="MediaId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="MediaExt" Type="nvarchar" Nullable="false" MaxLength="5" />
<Property Name="PostId" Type="int" Nullable="false" />
<Property Name="SynthId" Type="uniqueidentifier" />
</EntityType>
<EntityType Name="Posts">
<Key>
<PropertyRef Name="PostId" />
</Key>
<Property Name="PostId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="PosterID" Type="uniqueidentifier" Nullable="false" />
<Property Name="BundleId" Type="int" Nullable="false" />
<Property Name="LocationId" Type="int" Nullable="false" />
<Property Name="Tags" Type="uniqueidentifier" />
<Property Name="Quanitity" Type="int" Nullable="false" />
<Property Name="Description" Type="text" Nullable="false" />
<Property Name="ResourceNameId" Type="int" Nullable="false" />
<Property Name="Date" Type="datetime" Nullable="false" />
</EntityType>
<EntityType Name="ResourceEdges">
<Key>
<PropertyRef Name="EdgeId" />
</Key>
<Property Name="Rank" Type="int" Nullable="false" />
<Property Name="EdgeId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="ToResourceId" Type="int" Nullable="false" />
<Property Name="FromResourrceId" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="ResourceNames">
<Key>
<PropertyRef Name="ResourceNameId" />
</Key>
<Property Name="ResourceNameId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="100" />
<Property Name="ResourceId" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="Resources">
<Key>
<PropertyRef Name="ResourceId" />
</Key>
<Property Name="ResourceId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="Description" Type="nvarchar" MaxLength="50" />
</EntityType>
<EntityType Name="sysdiagrams">
<Key>
<PropertyRef Name="diagram_id" />
</Key>
<Property Name="name" Type="nvarchar" Nullable="false" MaxLength="128" />
<Property Name="principal_id" Type="int" Nullable="false" />
<Property Name="diagram_id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="version" Type="int" />
<Property Name="definition" Type="varbinary(max)" />
</EntityType>
<EntityType Name="Users">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="uniqueidentifier" Nullable="false" />
<Property Name="LocationId" Type="int" />
</EntityType>
<EntityType Name="Votes">
<Key>
<PropertyRef Name="VoteId" />
</Key>
<Property Name="VoteId" Type="int" Nullable="false" />
<Property Name="VoterId" Type="uniqueidentifier" Nullable="false" />
<Property Name="VoteContent" Type="int" Nullable="false" />
<Property Name="PostId" Type="int" Nullable="false" />
</EntityType>
<Association Name="FK_Comments_Offers">
<End Role="Offers" Type="XDbModel.Store.Offers" Multiplicity="0..1" />
<End Role="Comments" Type="XDbModel.Store.Comments" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Offers">
<PropertyRef Name="OfferID" />
</Principal>
<Dependent Role="Comments">
<PropertyRef Name="OfferPostID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Comments_Users">
<End Role="Users" Type="XDbModel.Store.Users" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="Comments" Type="XDbModel.Store.Comments" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="Comments">
<PropertyRef Name="UserID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_LocationPoints_Locations">
<End Role="Locations" Type="XDbModel.Store.Locations" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="LocationPoints" Type="XDbModel.Store.LocationPoints" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Locations">
<PropertyRef Name="LocationId" />
</Principal>
<Dependent Role="LocationPoints">
<PropertyRef Name="LocationId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_PostBundleJunction_Bundles">
<End Role="Bundles" Type="XDbModel.Store.Bundles" Multiplicity="1" />
<End Role="PostBundleJunction" Type="XDbModel.Store.PostBundleJunction" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Bundles">
<PropertyRef Name="BundleId" />
</Principal>
<Dependent Role="PostBundleJunction">
<PropertyRef Name="BundleId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_PostBundleJunction_Posts">
<End Role="Posts" Type="XDbModel.Store.Posts" Multiplicity="1" />
<End Role="PostBundleJunction" Type="XDbModel.Store.PostBundleJunction" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Posts">
<PropertyRef Name="PostId" />
</Principal>
<Dependent Role="PostBundleJunction">
<PropertyRef Name="PostId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Posts_Locations">
<End Role="Locations" Type="XDbModel.Store.Locations" Multiplicity="1" />
<End Role="Posts" Type="XDbModel.Store.Posts" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Locations">
<PropertyRef Name="LocationId" />
</Principal>
<Dependent Role="Posts">
<PropertyRef Name="LocationId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Posts_ResourceNames">
<End Role="ResourceNames" Type="XDbModel.Store.ResourceNames" Multiplicity="1" />
<End Role="Posts" Type="XDbModel.Store.Posts" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="ResourceNames">
<PropertyRef Name="ResourceNameId" />
</Principal>
<Dependent Role="Posts">
<PropertyRef Name="ResourceNameId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Posts_Users">
<End Role="Users" Type="XDbModel.Store.Users" Multiplicity="1" />
<End Role="Posts" Type="XDbModel.Store.Posts" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="Posts">
<PropertyRef Name="PosterID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_ResourceEdges_Resources">
<End Role="Resources" Type="XDbModel.Store.Resources" Multiplicity="1" />
<End Role="ResourceEdges" Type="XDbModel.Store.ResourceEdges" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Resources">
<PropertyRef Name="ResourceId" />
</Principal>
<Dependent Role="ResourceEdges">
<PropertyRef Name="ToResourceId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_ResourceEdges_Resources1">
<End Role="Resources" Type="XDbModel.Store.Resources" Multiplicity="1" />
<End Role="ResourceEdges" Type="XDbModel.Store.ResourceEdges" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Resources">
<PropertyRef Name="ResourceId" />
</Principal>
<Dependent Role="ResourceEdges">
<PropertyRef Name="FromResourrceId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_ResourceNames_Resources">
<End Role="Resources" Type="XDbModel.Store.Resources" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="ResourceNames" Type="XDbModel.Store.ResourceNames" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Resources">
<PropertyRef Name="ResourceId" />
</Principal>
<Dependent Role="ResourceNames">
<PropertyRef Name="ResourceId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Users_Locations">
<End Role="Locations" Type="XDbModel.Store.Locations" Multiplicity="0..1">
<OnDelete Action="Cascade" />
</End>
<End Role="Users" Type="XDbModel.Store.Users" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Locations">
<PropertyRef Name="LocationId" />
</Principal>
<Dependent Role="Users">
<PropertyRef Name="LocationId" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_Votes_Posts">
<End Role="Posts" Type="XDbModel.Store.Posts" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="Votes" Type="XDbModel.Store.Votes" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Posts">
<PropertyRef Name="PostId" />
</Principal>
<Dependent Role="Votes">
<PropertyRef Name="PostId" />
</Dependent>
</ReferentialConstraint>
</Association>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="XDbModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="XDbEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Bundles" EntityType="XDbModel.Bundle" />
<EntitySet Name="CellProviders" EntityType="XDbModel.CellProvider" />
<EntitySet Name="Comments" EntityType="XDbModel.Comment" />
<EntitySet Name="LocationPoints" EntityType="XDbModel.LocationPoint" />
<EntitySet Name="Locations" EntityType="XDbModel.Location" />
<EntitySet Name="Offers" EntityType="XDbModel.Offer" />
<EntitySet Name="PostMedias" EntityType="XDbModel.PostMedia" />
<EntitySet Name="Posts" EntityType="XDbModel.Post" />
<EntitySet Name="ResourceEdges" EntityType="XDbModel.ResourceEdge" />
<EntitySet Name="ResourceNames" EntityType="XDbModel.ResourceName" />
<EntitySet Name="Resources" EntityType="XDbModel.Resource" />
<EntitySet Name="sysdiagrams" EntityType="XDbModel.sysdiagram" />
<EntitySet Name="Users" EntityType="XDbModel.User" />
<EntitySet Name="Votes" EntityType="XDbModel.Vote" />
<AssociationSet Name="FK_Comments_Offers" Association="XDbModel.FK_Comments_Offers">
<End Role="Offers" EntitySet="Offers" />
<End Role="Comments" EntitySet="Comments" />
</AssociationSet>
<AssociationSet Name="FK_Comments_Users" Association="XDbModel.FK_Comments_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Comments" EntitySet="Comments" />
</AssociationSet>
<AssociationSet Name="FK_LocationPoints_Locations" Association="XDbModel.FK_LocationPoints_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="LocationPoints" EntitySet="LocationPoints" />
</AssociationSet>
<AssociationSet Name="FK_Posts_Locations" Association="XDbModel.FK_Posts_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_Users_Locations" Association="XDbModel.FK_Users_Locations">
<End Role="Locations" EntitySet="Locations" />
<End Role="Users" EntitySet="Users" />
</AssociationSet>
<AssociationSet Name="FK_Posts_ResourceNames" Association="XDbModel.FK_Posts_ResourceNames">
<End Role="ResourceNames" EntitySet="ResourceNames" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_Posts_Users" Association="XDbModel.FK_Posts_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
<AssociationSet Name="FK_Votes_Posts" Association="XDbModel.FK_Votes_Posts">
<End Role="Posts" EntitySet="Posts" />
<End Role="Votes" EntitySet="Votes" />
</AssociationSet>
<AssociationSet Name="FK_ResourceEdges_Resources" Association="XDbModel.FK_ResourceEdges_Resources">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceEdges" EntitySet="ResourceEdges" />
</AssociationSet>
<AssociationSet Name="FK_ResourceEdges_Resources1" Association="XDbModel.FK_ResourceEdges_Resources1">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceEdges" EntitySet="ResourceEdges" />
</AssociationSet>
<AssociationSet Name="FK_ResourceNames_Resources" Association="XDbModel.FK_ResourceNames_Resources">
<End Role="Resources" EntitySet="Resources" />
<End Role="ResourceNames" EntitySet="ResourceNames" />
</AssociationSet>
<AssociationSet Name="PostBundleJunction" Association="XDbModel.PostBundleJunction">
<End Role="Bundles" EntitySet="Bundles" />
<End Role="Posts" EntitySet="Posts" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Bundle">
<Key>
<PropertyRef Name="BundleId" />
</Key>
<Property Name="BundleId" Type="Int32" Nullable="false" />
<NavigationProperty Name="Posts" Relationship="XDbModel.PostBundleJunction" FromRole="Bundles" ToRole="Posts" />
</EntityType>
<EntityType Name="CellProvider">
<Key>
<PropertyRef Name="CellProviderID" />
</Key>
<Property Name="CellProviderID" Type="Guid" Nullable="false" />
</EntityType>
<EntityType Name="Comment">
<Key>
<PropertyRef Name="CommentID" />
Ah, it's actually very simple, once you think about it..
What you're trying to do it add the resource to the data context, even though this resource object was received from the database in the first place. So the error is not complaining about your child objects, but about your parent object! :)
Basically if you comment the first line in the SaveResource() method it should just work fine!
E.g.:
public void SaveResource(Resource resource)
{
// context.AddToResources(resource); //Should also add children.
context.SaveChanges();
}
Or just move the AddChildResource method to your DAL:
public void AddChildResource(int parentResourceId, Resource childResource)
{
Resource parentResource = repository.GetResource(parentResourceId);
ResourceEdge inEdge = new ResourceEdge();
inEdge.ToResource = childResource;
parentResource.ToEdges.Add(inEdge);
context.SaveChanges();
}
Presumably it's complaining about the childResource not being in the added state. You added it to the edge object that is in the added state.
Can you try flipping the way you set that association round:-
public void AddChildResource(int parentResourceId, Resource childResource)
{
Resource parentResource = repository.GetResource(parentResourceId);
ResourceEdge inEdge = new ResourceEdge();
// inEdge.ToResource = childResource; <-- don't do this
parentResource.ToEdges.Add(inEdge);
childResource.FromEdges.Add(inEdge); // try this instead
repository.SaveResource(parentResource);
}

Resources