How to set the output file name in Alfresco? - java

I was creating custom content model
in datalistModel.xml
<type name="dl:car">
<title>Car List</title>
<parent>dl:dataListItem</parent>
<properties>
<property name="dl:carName">
<title>Car Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="dl:carCompany">
<title>Company Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</type>
in share-datalist-form-config.xml
<!-- dl:contact type create car form -->
<config evaluator="model-type" condition="dl:car">
<forms>
<!-- Create item form -->
<form>
<field-visibility>
<!-- dl:contact type -->
<show id="dl:carName" />
<show id="dl:carCompany" />
</field-visibility>
<create-form template="../data-lists/forms/dataitem.ftl" />
</form>
</forms>
</config>
When I create a new car content in repository browser(I later configured menu to add content type 'Car'), the file name is 91b65385-86c6-4923-859d-6ecb3326319c.
<create-content>
<content id="plain-text" mimetype="text/plain" label="create-content.text" itemid="cm:content" icon="text"/>
<content id="html" mimetype="text/html" label="create-content.html" itemid="cm:content"/>
<content id="xml" mimetype="text/xml" label="create-content.xml" itemid="cm:content"/>
<content id="car" mimetype="text/xml" icon="xml" label="create-content.car" itemid="dl:car"/>
</create-content>
How can I make the file name to carName instead of 91b65385-86c6-4923-859d-6ecb3326319c
Any kind help is appreciated.

Take a look at the default 'share-datalist-form-config.xml'
You will see that almost every type specify <show id="cm:title" />
You could also just put <show id="name" /> or <show id="cm:name" /> to show the name attribute.
In order to put the title you will need to put the cm:titled aspect in your model.
Just check the 'datalistModel.xml' how the defaults are defined
And check this blog post to know a bit more how to create custom datalists.

Related

Use WIX feature element in wxi and wxs with same Id

I want to generate a MSI package which contains only one feature.
I have a wxi file which is generated automatically. I cannot change this process.
wxi file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<Include>
<!-- components -->
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="comp0" />
<ComponentRef Id="comp1" />
<ComponentRef Id="comp2" />
<ComponentRef Id="comp3" />
<ComponentRef Id="CleanupMainApplicationFolder" />
</Feature>
</Include>
I have a wxs file which I can change:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product ...>
<!-- components -->
<?include bundle.wxi ?>
<UI/>
<FeatureRef Id="DefaultFeature">
<ComponentRef Id="comp999" />
</FeatureRef>
</Product>
</Wix>
When I compile the wxs to MSI package Light is stating this error:
error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.
How do I change my wxs file to add a component to the feature defined in wxi file?
Thanks in advance.
Use <ComponentGroup> in your include files instead of <Feature>. Then, define your features in one place, the main .wxs file with <Product> element.
For example, this is how include file might look:
<Fragment>
<Component Id="Comp1" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp2" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp3" Guid="{GUID-GOES-HERE}">
...
</Component>
<ComponentGroup Id="CG1">
<ComponentRef Id="Comp1"/>
<ComponentRef Id="Comp2"/>
<ComponentRef Id="Comp3"/>
</ComponentGroup>
</Fragment>
And the main product.wxs defines the feature, includes the component group in there and allows including more components:
<Feature Id="MainFeature" Title="..." Level="100">
<ComponentGroupRef Id="CG1"/>
<!-- More components can go here -->
<Component Id="..">
</Component>
</Feature>
Moreover, you can include wxs files instead of include, too. As long as the main wxs references at least one element from another wxs, the entire contents will be included.

Spring call Jndi variable to jsp

I have some difficulties to call a JNDI variable to my jsp Page.
Context.xml :
<!-- Environnement de l'application -->
<Environment name="app/env" override="false" type="java.lang.String" value="Développement" />
conf-view-spring.xml
<jee:jndi-lookup id="jndiLookEnv" jndi-name="app/env"
expected-type="java.lang.String" />
footer.jsp
<div class="panel-footer footerstick clearfix">
<div class="pull-right">
<strong><c:out value="${jndiLookEnv}"></c:out></strong>
</div>
</div>
I have no error but my jndiLookEnv is empty,
What's wrong in this case?
Thank you.
Beans in the context aren't accessible by the JSP (or at least not in the way you are trying to). You would need a scriptlet to get access to the ApplicationContext and do a getBean to retrieve the value. Using ${jndiLookEnv} isn't going to work.
To make it available for easy use in the JSP you need to add a ServletContextAttributeExporter to expose it.
<bean class="org.springframework.web.context.suppor.ServletContextAttributeExporter">
<property name="attributes">
<map>
<entry key="env" value-ref="jndiLookEnv" />
</map>
</properties>
</bean>
Now you can use ${env} to reference to value.
Now you can improve on this and remove the JNDI lookup al together (assuming that you are on a recent spring version).
<bean class="org.springframework.web.context.suppor.ServletContextAttributeExporter">
<property name="attributes">
<map>
<entry key="env" value="#{environment['app/env']}" />
</map>
</properties>
</bean>
The Environment abstraction will do a lookup for the property in various locations, one of them being JNDI (you could override the app/env property using properties or a system property for instance.

Parsing xml with many attributes using Java JAXB

I have following xml which I am trying to parse using JAXB.
<?xml version="1.0" encoding="UTF-8"?>
<DataSet Name="core_donor" Version="2-0" SchemaVersion="1-0" SchemaDate="2014-01-16">
<DataPoints>
<DataPoint Name="donor_id" Value="105272" />
<DataPoint Name="surname" Value="TWO" />
<DataPoint Name="forename" Value="SCENARIO" />
<DataSubSet Name="blood_gas">
<DataPoints>
<DataPoint Name="blood_gas_no" Value="1" />
<DataPoint Name="blood_gas_date" Value="07/10/2014 10:15" />
</DataPoints>
<DataPoints>
<DataPoint Name="blood_gas_no" Value="2" />
<DataPoint Name="blood_gas_date" Value="07/10/2014 11:20" />
</DataPoints>
</DataSubSet>
<DataSubSet Name="liver_function">
<DataPoints>
<DataPoint Name="liver_function_no" Value="1" />
<DataPoint Name="liver_function_sample_date" Value="07/10/2014 11:10" />
</DataPoints>
<DataPoints>
<DataPoint Name="liver_function_no" Value="2" />
<DataPoint Name="liver_function_sample_date" Value="07/10/2014 13:52" />
</DataPoints>
</DataSubSet>
</DataPoints>
</DataSet>
I would be thankful if someone could point me how to achieve the parsing in java using JAXB.
Thanks!
For starters follow the below example
http://www.mkyong.com/java/jaxb-hello-world-example/
But DataPoints will be your RootElement , if am not wrong also refererence
check some examples for DOM parsing to traverse over the child nodes and read them.

JSP markup inside <tiles:put> or a or an alternative

I've inherited an old application that is using Struts 1.2 Tiles 1. For various annoying reasons I can't upgrade.
I'm not very familiar with Struts, or specifically Tiles in general and I'm trying to do something that makes sense in my head but I can't seem to make work in practice. Here's an example of what I'm trying to accomplish:
<tiles-definition>
<definition name="content-with-sidebar" path="/content_with_sidebar.jsp">
<put name="top" value="" type="string" />
<put name="sidebar" value="/tiles/sidebar.jsp" />
<put name="main" value="" type="string" />
<put name="bottom" value="" type="string" />
</definition
</tiles-definition>
content_with_sidebar.jsp
...
<tiles:insert attribute="top" flush="false" />
<div id="content">
<aside>
<tiles:insert attribute="sidebar" flush="false" />
</aside>
<div id="main">
<tiles:insert attribute="main" flush="false" />
</diV>
</div>
<tiles:insert attribute="top" flush="false" />
...
actual_page.jsp
<tiles:insert definition="content-with-sidebar" flush="false">
<tiles:put name="top" type="string">
<div>Maybe this page has something on the top that isn't the page header</div>
</tiles:put>
<!-- use the default sidebar -->
<tiles:put name="main">
<strong>Current Location:</strong>
<address><h:outputText value="#{locationDesc} #{zipCode}" /></address>
<!-- Some more dynamic jsp markup -->
</tiles:put>
<!-- This one doesn't have anything extra on the bottom -->
</tiles:insert>
This almost works but the dynamic bits get rendered above and outside the <tiles:insert> and the plain strings go where they should. I understand now, after much searching, that <tiles:put> in this, er, context, is expecting a plain ole string.
Is there a pattern to accomplish what I want with dynamic context?
As it stands I'm having to create another jsp file to be referenced by the <tiles:put> tag. i.e.
<tiles:put name="main" value="/actual_page_body.jsp" />
I'd rather not have to create an additional file when one would do. Any advice would be helpful.
With tiles, when the definition is rendered (content-with-sidebar in your code), the jsp corresponding to the 'path' attribute (/content_with_sidebar.jsp) will be invoked. All other jsps have to be manually invoked using a <tiles:insert>. What tiles provides you is a way to configurationally invoke them as definition attributes.

JAXB Parsing an XML file with variables (e.g. $(var1) )

I'm interested to parse an XML that contains variables (which are defined by me inside the XML).
Here's an example of the XML files:
<parameters>
<parameter name="parent-id" value="1" />
<parameter name="child-id" value="1" />
</parameters>
<Parents>
<Parent id="$(parent-id)">
<Children>
<Child id="$(child-id)">
</Child>
</Children>
</Parent>
</Parents>
Is there a utility or some standard way to do so in Java? (using JAXB possibly)
Or should I implement this "mini" parsing mechanism by myself?
(A mechanism that identifies the variables and plants them inside the XML, and only later calls JAXB flows)
Thanks a lot in advance!
Use an XSLT transformation to convert your XML into an XSLT stylesheet and then execute the XSLT stylesheet. It's simple enough to convert
<parameters>
<parameter name="parent-id" value="1" />
<parameter name="child-id" value="1" />
</parameters>
into
<xsl:param name="parent-id" select="1" />
<xsl:param name="child-id" select="1" />
and
<Parent id="$(parent-id)">
into
<Parent id="{$parent-id}">
and to add a wrapper xsl:stylesheet and xsl:template element, and then you're done.

Categories

Resources