| Author |
Message |
Matias Woloski
Guest
|
Posted:
Thu Sep 08, 2005 8:53 pm Post subject:
multiple problems with document libraries |
|
|
I'm using SPS 2003, but this is something regards WSS.
I need to do these things:
a.. Upload a list template (.stp) programatically
b.. Create a Document Library from a template that has 2 custom views
apart from "All Documents" and "Explorer View". The code I have for this is
[1] and it's working, however when I go to the portal via the browser, while
the doc lib is in the gallery, but doesn't have the custom views I've
defined in my template.
c.. Change the view of a webpart programatically. The code I have for this
is [2]. First, The custom views are not available in the Views collection.
Second, If I change the view to Explorer View the webpart still shows All
Documents view. That means that changing the ViewGuid is not working.
I need some workaround. If the solution is using webservices I have no
problem, but I need this working. Thanks!
[1] ********* Create a doc lib using my custom template ********
Uri serverUri = new Uri(portalUrl);
TopologyManager tm = new TopologyManager();
PortalContext pc = PortalApplication.GetContext(
tm.PortalSites[serverUri]);
Guid homeID = AreaManager.GetSystemAreaGuid(pc, SystemArea.Home);
Area parent = AreaManager.GetArea(pc, homeID);
SPWeb web = parent.Areas[ subarea ] .Web;
SPListTemplateCollection templates = web.Site.GetCustomListTemplates(
web);
Guid folderId = web.Lists.Add( doclib, String.Empty, templates[0],
web.DocTemplates[0] ); <-- Adding the doc lib using my custom template
which has some custom views
SPList folderList = web.Lists[folderId];
// Save the list configuration in WSS
folderList.Update();
[2] ***** adding the doc lib created to the webpartcollection ******
ListViewWebPart listViewWebPart = new ListViewWebPart();
listViewWebPart.IsIncluded = true;
listViewWebPart.ZoneID = "MiddleLeftZone";
listViewWebPart.ListName = folderList.ID.ToString("B").ToUpper();
listViewWebPart.ViewGuid =
folderList.Views[viewName].ID.ToString("B").ToUpper(); <--- Here I'm using
the Views
SPWebPartCollection webPartCollection =
web.GetWebPartCollection("default.aspx", Storage.Shared);
System.Guid storageKey = webPartCollection.Add(listViewWebPart);
Matias |
|
| Back to top |
|
 |
Mike Walsh
Guest
|
Posted:
Fri Sep 09, 2005 8:52 am Post subject:
Re: multiple problems with document libraries |
|
|
Please in any case post to only one of the two newsgroups.
Virtually all WSS questions could also be posted to a SPS newsgroup
following your logic.
Do you really want the SPS newsgroups swamped with copies of them all ?
Mike Walsh, Helsinki, Finland
WSS FAQ http://wss.collutions.com
please reply to the newsgroup only
private questions are not answered
"Matias Woloski" <southy@community.nospam> wrote in message
news:%238XXFHLtFHA.904@tk2msftngp13.phx.gbl...
| Quote: | I'm using SPS 2003, but this is something regards WSS.
I need to do these things:
a.. Upload a list template (.stp) programatically
b.. Create a Document Library from a template that has 2 custom views
apart from "All Documents" and "Explorer View". The code I have for this
is [1] and it's working, however when I go to the portal via the browser,
while the doc lib is in the gallery, but doesn't have the custom views
I've defined in my template.
c.. Change the view of a webpart programatically. The code I have for
this is [2]. First, The custom views are not available in the Views
collection. Second, If I change the view to Explorer View the webpart
still shows All Documents view. That means that changing the ViewGuid is
not working.
I need some workaround. If the solution is using webservices I have no
problem, but I need this working. Thanks!
[1] ********* Create a doc lib using my custom template ********
Uri serverUri = new Uri(portalUrl);
TopologyManager tm = new TopologyManager();
PortalContext pc = PortalApplication.GetContext(
tm.PortalSites[serverUri]);
Guid homeID = AreaManager.GetSystemAreaGuid(pc, SystemArea.Home);
Area parent = AreaManager.GetArea(pc, homeID);
SPWeb web = parent.Areas[ subarea ] .Web;
SPListTemplateCollection templates = web.Site.GetCustomListTemplates(
web);
Guid folderId = web.Lists.Add( doclib, String.Empty, templates[0],
web.DocTemplates[0] ); <-- Adding the doc lib using my custom template
which has some custom views
SPList folderList = web.Lists[folderId];
// Save the list configuration in WSS
folderList.Update();
[2] ***** adding the doc lib created to the webpartcollection ******
ListViewWebPart listViewWebPart = new ListViewWebPart();
listViewWebPart.IsIncluded = true;
listViewWebPart.ZoneID = "MiddleLeftZone";
listViewWebPart.ListName = folderList.ID.ToString("B").ToUpper();
listViewWebPart.ViewGuid =
folderList.Views[viewName].ID.ToString("B").ToUpper(); <--- Here I'm
using the Views
SPWebPartCollection webPartCollection =
web.GetWebPartCollection("default.aspx", Storage.Shared);
System.Guid storageKey = webPartCollection.Add(listViewWebPart);
Matias
|
|
|
| Back to top |
|
 |
Wei-Dong XU [MSFT]
Guest
|
Posted:
Fri Sep 09, 2005 8:52 am Post subject:
RE: multiple problems with document libraries |
|
|
Hi Matias,
a. upload lis template programmatically
This could be done in code and the list template gallery is one list of the
WSS site with the url http://<wss site url>/_catalogs/lt/. The lt
abbreviation here means the list template. However, as I know, the
_catalogs/lt/ is treated as one special folder in WSS. We can't upload file
directly into this folder in WebDAV. Even using the SPFile.CopyTo method,
we still can't do that.
So I have one workaround for you on this: we could upload the list template
into the site and save the whole site as one Frontpage FWP file. For the
deployment, we could use the fwp file to restore into the new site and the
list template is included at the new site as well.
b. Two custom view in Document library
The document library template stored in different folder for WSS site and
SPS portal site. The WSS template is stored in
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\60\TEMPLATE\1033\STS
The SPS templates is located at:
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\60\TEMPLATE\1033\SPS*
Please check which area your document library is located and change the
corresponding doclib template.
c. change the view programmatically
Your code looks very good! But at the WSS dev, there is one golden rule:
must update the data to the server after the modification. After we change
the ViewGuid, the listviewwebpart internally assign the new guid to its
internal data member. Then we will need to call one update/savechange or
any similar method to persist the data into server. However, as I know,
there is no such method available in the object model. So we can't change
the view type programmatically.
Please feel free to let me know if you have any further question on this
matter.
Best Regards,
Wei-Dong XU
Microsoft Product Support Services
This posting is provided "AS IS" with no warranties, and confers no rights.
It is my pleasure to be of assistance. |
|
| Back to top |
|
 |
Matias Woloski
Guest
|
Posted:
Fri Sep 09, 2005 4:52 pm Post subject:
Re: multiple problems with document libraries |
|
|
Thanks Wei-Dong,
My answers/questions inline
| Quote: | a. upload lis template programmatically
So I have one workaround for you on this: we could upload the list
template
into the site and save the whole site as one Frontpage FWP file. For the
deployment, we could use the fwp file to restore into the new site and the
list template is included at the new site as well.
|
Could this be done programatically? can you drop some code?
| Quote: | b. Two custom view in Document library
The document library template stored in different folder for WSS site and
SPS portal site. The WSS template is stored in
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\60\TEMPLATE\1033\STS
The SPS templates is located at:
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\60\TEMPLATE\1033\SPS*
Please check which area your document library is located and change the
corresponding doclib template.
|
Inside those two folders I have many other folders (DOCTEMP, DWS, LISTS,
XML). But I can't see how this could help me.
I'm slightly confused of where the List Templates are in the object model. I
mean what are the differences between uploding the template using STSADM or
using Upload template via http://<wss site url>/_catalogs/lt/. Where can I
use the template? in every Area of my site? If I use this
"mySite.GetCustomListTemplates( myWeb )" I would get the list templates only
available on myWeb? If yes, I don't get how I choose to upload a template to
a specific web. Could you clarify all this?
| Quote: | c. change the view programmatically
Your code looks very good! But at the WSS dev, there is one golden rule:
must update the data to the server after the modification. After we change
the ViewGuid, the listviewwebpart internally assign the new guid to its
internal data member. Then we will need to call one update/savechange or
any similar method to persist the data into server. However, as I know,
there is no such method available in the object model. So we can't change
the view type programmatically.
|
: | So you are telling me that what I want to do is impossible? I need to do
it in some way, no matter how! If not my project won't deliver!
What if I use Views.asmx webservice? Is it possible?
| Quote: | Please feel free to let me know if you have any further question on this
matter.
|
Thanks a lot,
Matias |
|
| Back to top |
|
 |
Wei-Dong XU [MSFT]
Guest
|
Posted:
Mon Sep 12, 2005 12:52 pm Post subject:
Re: multiple problems with document libraries |
|
|
Hi Matias,
For the site template saving, I don't have the backup utility source code.
And for the WSS list template gallery, I think there is one concept we
should clarify here:
The list template in SPS/WSS has two kinds: template file stp and xml
format template.
As I know, it will not work in SPS site for uploading the WSS list
template. So I think the best is to define one custom list template (xml
format) to add the custom view in SPS. This way, at the deployment time, we
could only need to copy the template xml file directly to the sharepoint
folder, then create the portal in that template. After that, the user could
create the document library based on your custom template. This msdn
article introduces the template customization of Sharepoint for you:
Customizing SharePoint Sites and Portals: Using Templates and Site
Definitions, Part 2
http://msdn.microsoft.com/library/en-us/odc_SP2003_ta/html/ODC_SPSCustomizin
gSharePointSites2.asp
For the last problem, I am currently still researching this for you. If any
update, I will reply you at the first time.
Please feel free to let me know if you have any further question on this
matter.
Best Regards,
Wei-Dong XU
Microsoft Product Support Services
This posting is provided "AS IS" with no warranties, and confers no rights.
It is my pleasure to be of assistance. |
|
| Back to top |
|
 |
Wei-Dong XU [MSFT]
Guest
|
Posted:
Wed Sep 14, 2005 8:52 am Post subject:
Re: multiple problems with document libraries |
|
|
Hi Matias,
Based on my research, we have no way to save the view in the web part
programmatically. The site admin will require to change the web part view
manually. Another way, we could also configure one site well; then save the
site as one template for the deployment.
Please feel free to let me know if any question on this matter.
Best Regards,
Wei-Dong XU
Microsoft Product Support Services
This posting is provided "AS IS" with no warranties, and confers no rights.
It is my pleasure to be of assistance. |
|
| Back to top |
|
 |
|
|
|
|