I have a custom site definition I created that deploys a couple of custom page layouts. Does anyone know what needs to be done so that when a user uses my site definition to create a site, their default.aspx page is created using my custom page layout?
Below is the module section of my site definition:
<Modules>
<Module Name="DefaultHome" Url="$Resources:osrvcore,List_Pages_UrlName;" Path="">
<File Url="default.aspx" Type="GhostableInLibrary" >
<Property Name="Title" Value="Test Home Page" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyCustomPageLayout.aspx, My Custom PageLayout" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
<Property Name="PublishingPageContent" Value="Welcome to the My Test Publishing Site" />
</File>
</Module>
</Modules>
In your onet.xml file you need to set the DefaultPageLayout property like below
<!-- Publishing Feature -->
<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/Default.aspx" />
<Property Key="ChromeMasterUrl" Value="~SiteCollection/_catalogs/masterpage/MyMasterPage.master"/>
<Property Key="SimplePublishing" Value="True" />
<Property Key="VersioningOnPages" Value="Major" />
<Property Key="RequireCheckoutOnPages" Value="False" />
<Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx:~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
<Property Key="DefaultPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
<Property Key="AvailableWebTemplates" Value="ENTERWIKIRBKC#2;"/>
<Property Key="AllowSpacesInNewPageName" Value="false"/>
</Properties>
</Feature>
The default.aspx page in SiteDefinition created by VS inherits from webpart page. Make sure that you delete all the code and add the below. This has worked for me.
<%# Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%# Reference VirtualPath="~TemplatePageUrl" %>
<%# Reference VirtualPath="~masterurl/custom.master" %>
Related
I have developed a JSF application with JPA using Netbeans and GlassFish. It is working fine within the Netbeans environment. Now I want to deploy it a remote GlassFish server with different database settings. Is there any method I can give the database settings when it is deployed in the server for the first time and save the settings afterwords?
I have a persistence.xml file, but the database settings are there in glassfish-resources.xml file.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="HOPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>dsHiLap2</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
glassfish-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/ho" object-type="user" pool-name="connectionPoolHo">
<description/>
</jdbc-resource>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPoolHo" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="URL" value="jdbc:derby://localhost:1527/healthofice"/>
<property name="serverName" value="localhost"/>
<property name="PortNumber" value="1527"/>
<property name="DatabaseName" value="healthofice"/>
<property name="User" value="healthoffice"/>
<property name="Password" value="health"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsDec2012" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="derby_net_ho_hoPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="1527"/>
<property name="databaseName" value="ho"/>
<property name="User" value="ho"/>
<property name="Password" value="ho"/>
<property name="URL" value="jdbc:derby://localhost:1527/ho"/>
<property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsHo" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-resource enabled="true" jndi-name="ds2013Feb" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-resource enabled="true" jndi-name="drHoBuddhikaDesktop1" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-resource enabled="true" jndi-name="drHoBuddhikaLaptop1" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-resource enabled="true" jndi-name="dsHiLap" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="derby_net_ho1_ho1Pool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="1527"/>
<property name="databaseName" value="ho1"/>
<property name="User" value="ho1"/>
<property name="Password" value="ho1"/>
<property name="URL" value="jdbc:derby://localhost:1527/ho1"/>
<property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsHiLap2" object-type="user" pool-name="derby_net_ho1_ho1Pool"/>
</resources>
You need to use GlassFish deployment plan to configure different connection pool settings for your remote GlassFish server, since glassfish-resources.xml defined application-scoped resources. The application-scoped connection pool is only created during the application deployment. Please see To Deploy an Application or Module by Using a Deployment Plan. Basically your supply a remote server version of glassfish-resources.xml (following module-name.gf-dd-name naming convention) in the deploymentplan.jar.
Another option is not to use the application-scoped resource. You can define the connection pool/data source through the GlassFish Admin console.
I created a custom sitedefinition. In my sitedefition i want to activate a custom feature (i add the guid into my onet.xml).
My custom feature for adding the webpart to the page is creating an error. The error is default.aspx is not found. I thought a page in a sitedefition is created first. After that feature will be activate. Why i receive an error?
SPLimitedWebPartManager collWebParts = web.GetLimitedWebPartManager("default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
collWebParts.AddWebPart(CustomWebPart, "MainLeft", 1);
collWebParts.SaveChanges(CustomWebPart);
collWebParts.Web.Dispose();
You'd better add you webparts in modules in onet.xml. Just add the tag and use the tag to provision your particular webparts.
A simple sample:
<Modules>
<Module Name="DefaultBlank" Url="" Path="">
<File Url="default.aspx" Path="default.aspx">
<AllUsersWebPart WebPartOrder="0" WebPartZoneID="Right" ID="g_bdef0b56_c2f4_4c5a_bc39_2908a0f61410">
<![CDATA[<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="***.LatestDiscussionsWebPart.LatestDiscussionsWebPart, ***, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20cca094e7d0240a" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="AllowZoneChange" type="bool">True</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="HelpUrl" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="TitleUrl" type="string" />
<property name="Description" type="string">Latest Discussions WebPart</property>
<property name="AllowHide" type="bool">True</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="Title" type="string">Latest Discussions </property>
<property name="ChromeType" type="chrometype">Default</property>
<property name="AllowConnect" type="bool">True</property>
<property name="Width" type="unit" />
<property name="Height" type="unit" />
<property name="HelpMode" type="helpmode">Navigate</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="AllowEdit" type="bool">True</property>
<property name="TitleIconImageUrl" type="string" />
<property name="Direction" type="direction">NotSet</property>
<property name="AllowClose" type="bool">True</property>
<property name="ChromeState" type="chromestate">Normal</property>
</properties>
</data>
</webPart>
</webParts>]]>
</AllUsersWebPart>
</File>
</Module>
Good luck.
(I have also asked this question on SharePoint Overflow.)
I have a SharePoint feature I'm using to add some custom aspx files to the Pages Library.
When I activate the feature, I can visit the pages in-browser and they are visible in SPDesigner, but when I "View All Site Content" they are not there.
Why is this the case?
The Feature's Elements File:
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" IgnoreIfAlreadyExists="False">
<Property Name="Title" Value="The Example" />
<Property Name="ContentType" Value="Page" />
</File>
</Module>
</Elements>
The Aspx File:
<%# Page language="C#" Inherits="System.Web.UI.Page,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" MasterPageFile="~masterurl/default.master"%>
<%-- deliberately left empty -->
(yup, it's empty!)
Addendum
When I "visit the pages in-browser" I mean navigate to their URLs manually: http://myserver:PORT/subsite/Pages/Example.aspx
When I "View All Site Content" I am looking at the contents of the "Pages" list: http://myserver:PORT/subsite/Pages/Forms/AllItems.aspx
I got an answer on SharePoint Overflow:
The File Node should have Type="GhostableInLibrary", because "Pages" is a document library. When ever you provision a file in a document library you need to have ghostableinlibrary set.
eg:
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="False">
<Property Name="Title" Value="The Example" />
<Property Name="ContentType" Value="Page" />
</File>
</Module>
</Elements>
So in the end the XML I'm using is...
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" IgnoreIfAlreadyExists="False" Type="GhostableInLibrary">
<Property Name="Title" Value="The Example" />
</File>
</Module>
</Elements>
I have a custom page-library which a custom content-type and a page-layout all inside a site-definition.
Works as expected. The only thing I cannot get around is that if I upgrade the solution with the page-lib, ctype, page-layout via stsadm everything is updated except the page-layout.
New fields in the ctype --> no problem
Changed views in the page-lib --> no problem
Updated PageLayout --> ERROR
The page-layout section:
<!-- specific page-layout to display LKW data -->
<File Url="CustomPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
<Property Name="Title" Value="$Resources:CustomLayouts,Title;" />
<Property Name="MasterPageDescription"
Value="$Resources:cmscore,PageLayout_BlankWebPartPage_Description;" />
<Property Name="ContentType"
Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingPreviewImage"
Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png" />
<Property Name="PublishingAssociatedContentType"
Value=";#$Resources:FieldsCTypes,cTypeDisplayName;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900D38AAFB8072F441984BC947D49503947;#" />
</File>
The relevant section in the onet.xml:
<Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;Custom" Path="">
<File Url="Default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title"
Value="$Resources:Layouts,DisplayName;" />
<Property Name="ContentType"
Value="$Resources:cmscore,contenttype_welcomepage_name;"/>
<Property Name="PublishingPageLayout"
Value="~SiteCollection/_catalogs/masterpage/CustomPage.aspx, $Resources:PalfingerPlatformsOrderRoot,LKWpageDefaultTitle;" />
<Property Name="PublishingPageContent"
Value="" />
</File>
</Module>
The strange thing is, if I just have a page-layout with no underlying page-library I can update the page-ayout.
The problem only occurs if I use a custom page-layout inside a custom page-library.
I did some Google search and found a hint - the problem could be that the page-layout is unghosted.
I checked this with a small sample code:
SPFile file = folder.Files["Default.aspx"];
if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
{
file.RevertContentStream();
}
After executing the code the Page-Layout is upgraded and uses the new page-layout.
The Problem is that this is no real solution for me because I have approx. 1000 site-collections using the site-def. and the page-layout.
Updating all of them is quite painful. Does anybody know a solution for this?
I would like to comment on one thing. Looks like IgnoreIfAlreadyExists="TRUE" is not working properly refer to this link, may be reverting the value to FALSE should help.
<File Url="CustomPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
I've developed a custom web part. I would like to create a feature that when activated via STSADM adds the web part to the default page of a WSS Site. Hopefully this can be done without writing code.
This webpart is meant to de deployed to the web application's bin directory and featurereceiver must be installed to the GAC. The AllUsersWebPart element looks promising, but I can't figure out how to get it to work.
TIA,
jt
The AllUsersWebPart tag allow us to insert one webpart and place it where we want using WebPartOrder and WebPartZone attributes. The content of the tag is the dwp (or webpart) of your webpart. For example, for a dwp:
<AllUsersWebPart WebPartZoneID="MiddleLeftZone" WebPartOrder="0">
<![CDATA[
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
<FrameType>None</FrameType>
<AllowMinimize>true</AllowMinimize>
<IsVisible>true</IsVisible>
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Value><iframe src="$Resources:Summary_Url;" frameborder="0" scrolling="no" width="100%" height="100%"></iframe></Value>
</Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
]]>
</AllUsersWebPart>
For a webpart:
<AllUsersWebPart WebPartZoneID="MiddleLeftZone" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f3b9d1137704f880" />
<importErrorMessage>No se puede importar este elemento Web.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="AllowClose" type="bool">False</property>
<property name="AllowMinimize" type="bool">False</property>
<property name="AllowConnect" type="bool">True</property>
<property name="ChromeType" type="chrometype">None</property>
<property name="Hidden" type="bool">False</property>
<property name="AllowEdit" type="bool">False</property>
<property name="AllowZoneChange" type="bool">False</property>
<property name="MissingAssembly" type="string">No se puede importar este elemento Web.</property>
<property name="ChromeState" type="chromestate">Normal</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>
I haven't tried before but I think it can be done once the web has been created. Try it and tell us.