WP8: PhoneApplicationPage.Resources - "Resources" is not recognized or is not accessible - windows-phone-8

I'm developing my first native Windows Phone 8 application, and I'm new to xaml.
I am trying to create a resources section to contain a DataTemplate using the following markup:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="LoopingSelectorTemplate">
<Grid>
<TextBlock Text="{Binding}" FontSize="32" Foreground="Green"></TextBlock>
</Grid>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
However I am getting an error 'The member "Resources" is not recognized or is not accessible.'
Am I missing a reference, or xmlns? Most search results I find seem to imply that the above markup should work out of the box, and don't mention needing anything else.
Edit:
When I try and build the solution I get the following errors:
'The member "Resources" is not recognized or is not accessible.'
"The attachable property 'Resources' was not found in type 'PhoneApplicationPage'"
and "The property 'Resources' does not exist on the type 'Grid' in the XML namespace 'clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone'"

The problem was that although I was adding this to the MainPage.xaml, it wasn't at the root phone:PhoneApplicationPage tag, but instead it was within a Grid tag.

Related

OmniFaces loading/unloading ViewScopedBean

Trying to narrow in on our issue we are upgrading from Jboss 6 EAP (JSF 2.1) to Jboss 7 EAP (JSF 2.2). Our working application now has an issue with OmniFaces ViewScoped beans.
Versions:
Mojarra 2.2.14
OminFaces 2.6.9
PrimeFaces 6.2.5
We have a datatable like this:
<p:dataTable id="tblLegalHolds" widgetVar="tableLegalHolds" var="row"
rowKey="#{row.id}" filterEvent="enter"
lazy="true"
value="#{bean.lazyDataModel}"
rows="15">
NOTE: Our bean is OmniFaces ViewScoped and our table is working fine at this point!
Problem:
Next we add a column that contains a navigation to a new page like this:
<p:column width="60" exportable="false">
<p:button value="Open" outcome="legal-hold-edit">
<f:param name="id" value="#{row.id}" />
</p:button>
</p:column>
Now our bean is getting loaded and unloaded immediately and if we do a View Source of the HTML we see the Omnifaces script added twice like so...
OmniFaces.Unload.init('f1c1ff81-c87f-4406-b98f-a3eaff977e96');
OmniFaces.Unload.init('45e7de9d-53c7-4426-a972-797c48c46733');
We added #PostConstruct to our ViewScoped beans to prove its getting called twice. Our faces-config.xml looks like this for that Navigation.
<navigation-case>
<from-outcome>legal-hold-edit</from-outcome>
<to-view-id>/legal/legal-hold-edit.xhtml</to-view-id>
<redirect include-view-params="true"/>
</navigation-case>
Now what is interesting is if we remove the "include-view-params" in faces-config.xml like the code below everything starts working fine the ViewScoped bean is created only once and only 1 OmniFaces.Unload.init script is added to the page.
<navigation-case>
<from-outcome>legal-hold-edit</from-outcome>
<to-view-id>/legal/legal-hold-edit.xhtml</to-view-id>
<redirect/>
</navigation-case>
As an added note our outcome page is using o:viewparam to receive the param like this:
<f:metadata>
<o:viewParam name="id" value="#{legalHoldForm.legalHold}" required="false" />
<f:event type="preInvokeAction" listener="#{controller.initializeViewLegalHold}" />
</f:metadata>
So my questions are:
Why does removing "include-view-params" make it work?
Is this a bug similar to this recent ViewScoped issue? : https://github.com/omnifaces/omnifaces/issues/463
This appears to be a bug in Mojarra. It's indirectly calling the PreDestroyViewMapEvent when figuring out the view parameters for the other view.
During the render response phase, when the URL for an UIOutcomeTarget component (e.g. <p:button>) is to be generated, and includeViewParams is set to true (as defined in your navigation case), then it needs to consult all <f:viewParam> of the target view. In order to achieve this, it will need to build an UIViewRoot instance of it.
However, it actually temporarily sets that new UIViewRoot as the current view root of the faces context in order to access the <f:viewParam>. It will restore the original view, but this is where it goes wrong in Mojarra. It is restoring context.setProcessingEvents(true) too early. It should actually have done it after restoring the original view.
For now, your best bet is to report this issue against Mojarra and avoid using includeViewParams in combination with OmniFaces #ViewScoped.
Issue reported: https://github.com/eclipse-ee4j/mojarra/issues/4503
PR Provided: https://github.com/eclipse-ee4j/mojarra/pull/4730
This fix will be included in 2.3.15, 3.0.1 and 4.0.0 of Mojarra.

How to hide some paths while browsing using the XType browsefield?

In my component dialog, I use browsefield XType to enable the user to browse through the page tree and select a page:
<page jcr:primaryType="cq:Widget"
fieldLabel="Page"
name="./path"
xtype="browsefield" />
At the same time, I would like to make some pages are invisible. Suppose I have the following structure:
pages/
page1/
page1_1/
page1_2/
How do I make pages/page1/page1_2 invisible, so that nobody can select it when he browses through the page tree?
browsefield is a deprecated xtype, it's replacement the pathfield has this feature. Pathfield has a property called predicate which can be used for filtering. You can create and register a custom predicate that returns false for the paths you don't want to be visible in the the dialog. The name of the custom predicate can then be passed to the config of pathfield.
You can find a detailed tutorial on this here : http://www.albertoalmagro.com/2013/05/adobe-cq5-create-predicate-pathfield.html
For more on predicates, the following links can be referred :
http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html
http://labs.sixdimensions.com/blog/2013-07-10/custom-predicateevaluators-or-how-i-learned-stop-worrying-and-love/

Set default navigation page to xaml in a library in WP8

My default page is in a library. How do I point this field to it?
Edit the XML code of your WMAppManifest.xml and replace the property NavigationPage of the following line:
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
to:
{assemblyName};component/{pathToResource}
where the assemblyName is the name of the assembly of the page you want to navigate to, and pathToResource is the path (inside that project) to the page you want to navigate to.

Overriding styling in Windows Phone 8

I have a dll that our customers integrate that provides UserControls and I want to allow style overrides. In Windows Store I can do:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///MyDLL/Assets/Styles/Default.xaml"/>
<ResourceDictionary Source="ms-appx:///OverrideStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
and it finds the local AppboyStyles.xaml defined in the users app. I can't figure out the right URI for Windows Phone 8 to allow similar functionality.
edit:
Say I have UserControl1 in A.dll, and UserControl1 has a style resource dictionary that looks like:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/A;component/Assets/Styles/Default.xaml"/>
<ResourceDictionary Source="/TestApp;component/Assets/Styles/Override.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
This will actually work in TestApp, but I can't hardcode one calling app because it's a library to be distributed. So I need a way to either substitute for the calling app dll name, or use a URI that evaluates to the current app's resources.

How to have pdf viewer in ruby

How can I embeded pdf viewer in ruby on rail?
Now I tried
<embed src="MyPdfDocument.pdf" width="500" height="375">
but it doesn't work. I used firebug and see the error like this
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIStreamListener.onStopRequest]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///home/bengasi/.mozilla/firefox/cmb1mbzu.default/extensions/firebug#software.joehewitt.com/components/firebug-channel-listener.js :: anonymous :: line 167" data: no]
[Break on this error] this.listener.onStopRequest(request, requestContext, statusCode);\n
firebug-...stener.js (line 167)
If you are trying to display a PDF as an image, surrounded by HTML content... then a browser won't do that, and your problem is with the browser, not Ruby on Rails. You can link to a PDF, and display it whole, but you cannot embed it in another document.
You could simulate the effect (maybe, in some browsers) with an iFrame, but that is a HTML question, not a rails question... and you would possibly spend a lot of time making it work in all browsers.
You might find this useful:
http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html