Plone 4: Create New Template View - view

I have created a new product. I am able to install and uninstall it.
However, I have created a view, callable from an action(actions.xml) but I keep getting an error saying the page does not exist
This page does not seem to exist…
here is my actions.xml
<?xml version="1.0"?>
<object name="portal_actions" meta_type="Plone Actions Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<action-provider name="portal_workflow"/>
<action-provider name="portal_types"/>
<action-provider name="portal_actions"/>
<object name="document_actions" meta_type="CMF Action Category">
<object name="viewCatTree" meta_type="CMF Action" i18n:domain="plone">
<property name="title" i18n:translate="">Category Tree</property>
<property name="description" i18n:translate=""></property>
<property name="url_expr">string:${object_url}/visual_tree_view</property>
<property name="icon_expr"></property>
<property name="available_expr"></property>
<property name="permissions">
<element value="View"/>
</property>
<property name="visible">True</property>
</object>
<!-- more actions here -->
</object>
This is how I've specified it in configure.zcml
<browser:page
for="*"
name="visual_tree_view"
class=".viewlets.CategoryTreeSettingsView"
template="../skins/category_customizations/category_view.pt"
permission="zope2.View"
/>
I've also tried adding the ## before the view name in the browser, but the page cannot be found. The template exists in the skins folder and it does not matter whether I change the above code to point to /templates/category_view.pt
Any ideas?

I suspect your view is raising an AttributeError or KeyError when rendered, which would also cause Plone to display a NotFound error.
Put a debug breakpoint in your view __call__ and / or __init__ methods to see if your view is being looked up and called.
That, or your configure.zcml is not being loaded at all; make sure your package is included somewhere, perhaps in the zcml variable in the plone.recipe.zope2instance part of your buildout, or in a <include /> statement in another configure.zcml file.

Related

Ensure ordered shutdown of bundles in karaf

For a simple use-case, I have two bundles in Karaf as:
Bundle-Shared-Library
Bundle-My-Implementation -> depends on (1) Bundle-Shared-Library, mentioned in blueprint via depends-on attribute of the bean
Steps that I am following:
Load Bundle(1)
Load Bundle(2)
Shutdown karaf
It is evident that (2) is dependent on (1). While shutting down Karaf, Bundle(1) gets removed first, this results in the loss of in-flight messages as it cannot find its dependency and cannot process further.
I tried setting the start level of (1) both higher and lower than that of bundle(2). This did not help.
Also, I tried setting org.apache.aries.blueprint.preemptiveShutdown=false in etc/config.properties. This did not help as well.
Am I missing something here?
-- EDIT 1 --
After looking a bit over here and there, I found out that we can set a custom value for timeout in DefaultShutdownStrategy. So, as a workaround, I have done following:
<bean id="shutdownStrategy" class="org.apache.camel.impl.DefaultShutdownStrategy">
<property name="timeout" value="1" />
</bean>
I understand that this is not a clean and optimal way to do. For the time being, it somehow helps me from losing a lot of in-flight messages.
But, any suggestion or feedback would be great.
-- EDIT 2 -- Adding Blueprint File of Bundle 1
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.3.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.3.0.xsd
">
<!-- persistent-id for shared context -->
<cm:property-placeholder persistent-id="xxx.shared" update-strategy="none" >
<cm:default-properties>
...
</cm:default-properties>
</cm:property-placeholder>
<!--jms broker connection-->
<reference id="jmsProducerConnectionFactory" interface="javax.jms.ConnectionFactory" filter="(osgi.jndi.service.name=jms/xxx.producer)" availability="mandatory" />
<bean id="xxx-producer" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsProducerConnectionFactory"/>
</bean>
<!-- Source DB Reference -->
<reference id="XDataSource" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=xxx-datasource)" availability="mandatory"/>
<!-- Datawarehouse DB Reference -->
<reference id="dw" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=xdb-datasource)" availability="mandatory"/>
<bean id="prs" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="XDataSource"/>
</bean>
<bean id="timestamp" class="org.library.shared.TimestampImplementation" destroy-method="synchronize" depends-on="dw">
<argument index="0" ref="dw" />
<argument index="2" value="Orders" />
</bean>
<bean id="shutdownStrategy" class="org.apache.camel.impl.DefaultShutdownStrategy">
<property name="timeout" value="1" />
</bean>
<camelContext id="camel-context" xmlns="http://camel.apache.org/schema/blueprint" depends-on="timestamp">
<packageScan>
<package>org.xyz.orders.routing</package>
</packageScan>
</camelContext>
</blueprint>
The other bundle is simply a collection of few classes (a shared library), which I have included as a maven dependency. There is no blueprint file for that bundle.
Due to organizational issues, I have used dummy names at some places.

libMobileGestalt MobileGestaltSupport.m:153: pid 1668 does not have sandbox access in Xcode console

I'm seeing this message in the Xcode console whenever I run the app:
libMobileGestalt MobileGestaltSupport.m:153: pid 1668 (APP_NAME) does not have sandbox access for frZQaejlsahdhlemg and IS NOT appropriately entitled
Using Apache Cordova, in my case, I had the same issue, and after some deep searches, I found it was originally (and stupidly) due to Splashscreen.
Check/add these lines in your config.xml file :
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="AutoHideSplashScreen" value="true" />
<feature name="SplashScreen">
<param name="ios-package" onload="true" value="CDVSplashScreen" />
</feature>
And then my app worked like a charm.
Hope this helps in your case.
After digging into it, I found that embedding a UIViewController -or any subclass of it- in a navigation controller is the main reason to show this error message.
I'm not sure what exactly makes the navigation controller show this message.
Edit 1:
After Xcode 9, I'm not seeing this issue anymore with new projects created in Xcode 9
Edit 2:
In Xcode 9, I saw the same error when working with CGRect.

Can not load property file in spring-context.xml. Property file Path is given as a placeholder in dev.properties

I am loading property file in spring-context.xml and i am giving
external property file location in
${spring.profiles.active}.properties which is in classpath and using the location as a placholder in spring-context.xml. My spring-context.xml is:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="searchSystemEnvironment" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="locations" ref="propertyConfigurerFiles" />
</bean>
<bean id="propertyConfigurerFiles" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>/WEB-INF/properties/common.properties</value>
<!--In Developemnet Enviroenment it will be dev.properties-->
<value>/WEB-INF/properties/${spring.profiles.active}.properties</value>
<!--External Property File Location as a Placeholder-->
<value>${app.config.batch.location}</value>
</list>
</constructor-arg>
</bean>
And my dev.properties is:
app.config.batch.location=E:/project/properties/config.properties
My problem is that is ${app.config.batch.location} placeholder is not
resolved in spring-context.xml and its trying to load file
${app.config.batch.location} in place of
E:/project/properties/config.properties.
I hope I explained the problem well. Please help!
Thanks in Advance!!!
You need to create bean of class PropertyPlaceHolderConfigurer.
Not just some ArrayList bean. Why do you think you need this ArrayList bean?
It seems you are using spring profiles, instead of messing with initialization time property value binding what you can do is ...
1) read the property file(profile's)
/WEB-INF/properties/${spring.profiles.active}.properties
2) create a java class that can read these property values. (don't forget to use spring profiles interfacing class)
3) as you are trying to read a property file whose location is embedded in property file(step-1), object created at step-2 will give value for key <value>${app.config.batch.location}</value>
now you can load this property file using available file reader class.
4) create Properties object and access the values in it.
Note:: if any of your bean initialization depends on key-value read at step-4, do initialization manually or create your ***custom class(servlet) that get loaded before any other class (even spring's DispactherServlet).

Update Views With Spring MVC And Thymeleaf Without Redeploy The App

I am using Spring MVC 3.2, Thymeleaf, Thymeleaf dialect with Tomcat and every time that I change a view I don't want redeploy my app. As suggested from others I am setting:
<property name="cacheable" value="false"/>
in the template resolver, but it not working.
Also a full reload (CTRL + F5) has not effect.
Here my full Thymeleaf configuration:
<!-- Thymeleaf template engine -->
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
<property name="cacheable" value="false"/>
</bean>
<bean id="templateEngine"
class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
<!-- These lines add the dialect to Thymeleaf -->
<property name="additionalDialects">
<set>
<bean class="nz.net.ultraq.thymeleaf.LayoutDialect"/>
</set>
</property>
</bean>
<bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
</bean>
Is there something else that I can do to resolve this issue?
It depends on many many things and mainly on "where and how" you update your view. If you are using a IDE (Netbeans or Eclipse) it main depend on the IDE itself and on the deployement process.
Current organization on disk :
Source directories => [ on build ] => target or build directories => [ on deploy ] => tomcat directories
But IDE often tries to be developper's friendly and it can happen that target directories and tomcat directories are the same. But it also may depend of the IDE and its configuration.
Also when you save files under source webapp, the IDE may automatically copy them to target.
But this is not guaranteed by <property name="cacheable" value="false"/> of Thymeleaf config. All what it guarantees is that if a template is changed in tomcat directories, next request will use it.
So to be sure where the problem really comes, you will have to find where tomcat actually gets the templates and if those templates are modified.
(and I didn't even talked of browsers cache ...)
In Tomcat "Server Options", check "Serve modules without publishing" did the trick for me.

Can you configure velocity to use a toolbox file from the classpath?

I'm using spring with a VelocityViewResolver configured by Spring
<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="order" value="1" />
<property name="suffix" value=".vm" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="toolboxConfigLocation" value="/WEB-INF/velocityToolbox.xml" />
</bean>
This works if the velocityToolbox.xml file is under WEB-INF ; however I'm trying to put it in the classpath. Is there a way to do it ?
I've tried specifying toolboxConfigLocation as "classpath:/wherever/velocityToolbox.xml", but it does not find the resource, and I end up with no toolbox configured, and a NPE at runtime (for some reason, it seems like the code expect the location to start with a '/', or add the '/' itself before looking for the resource).
Given that the resource is located using ServletContext.getResourceAsStream, with the content of the toolboxConfigLocation property prefixed by a "/", is there a way I can "define" a resource in my spring config that would somehow 'point' to an actuall classpath resource ?
Any idea is welcome.
I believe it has to be a full path, eg:
/WEB-INF/classes/com/myapp/resources/toolbox.xml
The ServletToolboxManager#getInstance(ServletContext context, String toolboxConfigLocation) method is used to generate a ToolboxManager configured with the toolbox in order to create the ChainedContext used in the VelocityToolboxView.
This method pre-appends the path with a '/' if one does not exist, and then uses ServletContext#getResourceAsStream(String path) to read it in.
With this in mind, you'll have success if you set it as a full path from the context root.

Resources