Custom SharePoint List View - can I put it in a feature (WSP)? - sharepoint

Here's my situation:
I'm working in SharePoint 2007 Enterprise, I have a feature that creates a list for me when I deploy and activate it. My usual workflow thus far has been to deploy the solution, activate it, then open up SharePoint Designer to customize the list.
My customizations are typically pretty complex, but I'll keep things simple. In this case, let's just say that I edit AllItems.aspx, convert the data view to an XSLT data view, then I add one column with static text.
I've used a few different tools (SPSource, VSeWSS, SharePoint Manager, OCDExportList, etc) to extract my custom schema.xml and all the default views, but I have yet to have any luck figuring out where the the code for AllItems.aspx is now that it's been customized.
When I extract (using any of the tools above) AllItems.aspx is no different than the default. The <View> element in schema.xml is reduced to one line, for example:
<View DefaultView="TRUE"
MobileView="TRUE"
MobileDefaultView="TRUE"
Type="HTML"
FPModified="TRUE"
DisplayName="All Documents"
Url="Forms/AllItems.aspx"
Level="1"
ContentTypeID="0x" />
I'm really stuck here... I've got no clue what to do. Is it even possible? It would save me a great amount of time (and documentation) if I could include my customizations in my feature.
If there's any other info I'm missing that would help, let me know... thanks!
Latest findings:
I've found out a bit more in the past couple hours. If I save the list as a List Template, then save the .stp file locally as a .cab file I can extract its contents. One of the files is manifest.xml which contains the schema.xml as well as a few other sections.
One of those sections is a <webparts> section that has a <webpart> for each view. Each of those <webpart> elements contains a really long string of characters... no clue what those characters actually represent.
The important thing is that I think any custom views have to actually be Web Parts if deployed as part of a solution... but I'm not positive.

I have faced a similar issue a while ago. I had to create a very customized view and I had to give up the ListFormWebPart completely, and have created my own webpart to render the data.
Generally, when you customize the aspx file in SPDesigner, all your changes will be in the aspx file itself. Open it in SPDesigner and you will see there all the changes you have made. After you have converted to the XSL Data View, the standard ListFormWebPart is replaced by a DataFormWebPart, which doesn't care about the <View> tags specified in the schema.xml; Look in the aspx file itself for the ListFormWebPart.
Why not do all the customizations you want on a list, save the list as a template (it will include the associated AllItems.aspx) and then use that template in your feature to create your list? You could add the extracolumn from code (if it's dynamic and cannot be included in the template), and so on.

Yes you can. Get the Sharepoint manager tool from Codeplex
http://spm.codeplex.com/
Install it on a machine in your farm, it will allow you to browse the farm via a tree view that shows all objects.
Make the list via the Sharepoint GUI, then browse to it w/ SPM.
SPM will allow you to extract the MOSS/WSS created xml that describes the list view (it shows up in the left hand property grid), which you can then plop into your manifest.xml

I have a similar issue and have been doing a lot of research into this. The dataview web part to me is one of the most powerful components in Sharepoint. Unfortunately I have to provide my solution as a .wsp package and that means that I can not just make the site and use Designer on that site. I have taken a 2 step approach in that I used designer to create my dataview and I also edited the code of that dataview to replace the ListID and Guids to ListName and the actual list name. This allows it to be exported and used in any page/site as long as the list name is the same. I am creating a webpart page document library also in my solution and I believe I can add the pages that have the webparts to this library using the onet.xml file. I will try to get the results of that test in as soon as I can do it.

Related

XPages: Is there a way to copy/rename custom controls

In Lotuscript you can manipulate design elements - create them, change them, rename them, etc.
Are you able to do the same thing for Xpages and custom controls design elements?
====================================================================
My question should have been clearer. What I want to accomplish is to copy an existing cc and give it a new name, programatically. The app will then close and reopen (or refresh or get rebuilt) so that the app can "see" the new cc. If I copy the cc it will only have one field on it. I will add custom code later. I could just create a new cc with no code in it, that would work too.
I am not familiar with the DXL exporter but I can research it. Using that can I just export the design of the cc to an XML file in a temp directory, use the transform to change the name, and then import the control?
I think the XPage or Custom Control design elements are probably under MISC_CODE or MISC_FORMAT design elements in a NoteCollection.
However, accessing that design element is the easy part. Doing a create / rename / change etc is a much bigger task.
Remember that the XPage or Custom Control XML file is only a starting point:
XPages and Custom Controls also have a .xsp.metadata file, as you'll see with source control.
Custom Controls will also have (and need) a .xsp-config file.
There are corresponding .java files for every XPage and Custom Control in the Local source folder. They're created by a builder based on parsing the XML. I don't think you'll be able to create those programmatically. I'm not sure of the impact of renaming them.
For Custom Controls, even if you can rename the .java file, it's referenced in the .java files of relevant XPages. Updating those is goiong to be a significant task.
The XPages runtime doesn't even use those .java files. Instead it uses the .class files in WebContent\WEB-INF (you need to use Project Explorer view and modify the filter to see those files). This is compiled byte code, so you won't be able to update the .class files for XPages containing renamed Custom Controls, as far as I know.
Even if you can rename the .class files, the XPages runtime almost certainly won't use them until either a Clean (which will overwrite anything you've done) or an HTTP restart. As far as I can tell they're cached.
Depending on your use cases, it's possible not all these points will be an issue, e.g. if you're modifying the XML files and building with headless designer.
I suspect this is why nothing was added to the NoteCollection object or a specific NotesXPage / NotesCustomControl API class added.
In Lotuscript you can manipulate design elements - create them, change them, rename them, etc.
This is only partially true. There is a LS API to create/alter views and outlines. Good luck with other design elements - although they're standard "notes", so you can access their items, in most cases you won't compile them and there will be some problems with signatures (real experience with TeamStudio CIAO).
Your question has two points of view - do you want to alter design elements in design process or alter running application?
To help a designer you can go the way of Eclipse extensions and enrich tools in IBM Designer to help developer. Something like TeamStudio Designer. In this case you need to look for source design elements, mentioned by Paul.
To enrich application you don't need to alter source design elements. IBM Designer transforms XML in source code to a Java code (JSF framework) - so you can generate your Java code from anything you wish. Take a look inside Local\xsp folder of NSF in Package explorer. You will find Java sources made from your XPages and Custom Controls. So if you don't need to work with design elements, go for Java components - they can be built on the fly.
And of course, there is always the option of DXL framework - so you can clone/alter design of the application through XML transformations. Good starting point: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/ls-design-programming.htm

Sharepoint - Custom ItemStyle in a new file

how can I customize the presentation of a Content Query Web Part by modyfing the xsl it uses without touching ItemStyle.xsl but using a brand new .xsl file?
I'm using MOSS 2007.
Thanks
There are lots of Articles on Customising the CQWP,
Healther Soloman's being one of my faves
here
But this
is a succint article doing exactly what you describe
using your own xsl by changing the Settings in the DWP (export/edit/import)
You could get really fancy and create your own version of the CQWP by inheriting from ContentByQueryWebPart and setting all the attributes you want in that code and including the files in you new feature to house said webpart and new files.

SharePoint 2007: How to upload multiple files to a List Item?

I know that a Document Library in SharePoint 2007 has a multi-file uploader (an ActiveX control that -- and only if you have Office 2003+ installed) but how would I use this same feature with a normal (non-document-library) List item?
Uploading files to a normal List item involves clicking the "upload" link and browsing/uploading files one by one. Is there a better way than this? Surely there must be.
Jake
There is an approach I use, but there is no UI support for it. You may find it a bit tedious for onsey-twosey uploads, but it saved me hours once for serious bulk uploads.
The same WebDAV functionality that we get when using "Open with Windows Explorer" on a document library is available for a list.
Say I have a list at http://myorg.com/sites/Widgets/Lists/MyList.
I can open the list in Windows Explorer by going to the address \\myorg.com\sites\Widgets\Lists\MyList.
Attachments are stored in the sub-folder Attachments, which contains folders with numeric names (1, 2, 3, ... and so on). The numbers correspond to the item ID of the list item. Pick (or create) a folder with the ID corresponding to the item you want to upload to, and it's drag-and-drop from there.
Short of writing your own mulit-file upload web part I think you are going to be stuck with either one at a time (i.e. an attachment to the list item) or switch to a document library. Don't forget that you can customise your library to behave much like a list.
Why is it a problem to use a document library?
I seem to be making a habit of answering my own questions. Not sure if that's a good thing or not.
What I ended up doing was adding an "Upload Multiple Files" button to the toolbar which pointed to a custom ASPX page in the _layouts folder. This page displayed the ActiveX component used by a Document Library and the "post to" URL for it was the ASPX page itself. When posted to it looked for files uploaded and attached them all to the List Item referenced via URL parameters passed to it from the toolbar button.
It's discussed here:
http://weblogs.asp.net/nathanyorke/archive/2007/12/05/uploading-multiple-files-via-the-web.aspx
If I get round to blogging and fuller explanation on my own site I'll try and remember to post a link back here.
Jake

Restore NewForm.aspx file

How do i restore a deleted NewForm.aspx file?
I dont want it back through the recycle bin, since i made a mess of it, i just want to recreate the original file.
Sharepoint 2003 was able to do this.
could you restore it from the recycle bin and then in sharepoint designer try a "restore to site definition" (right mouse click on the file). P.S. Never change the out of the box newform / editform etc. Copy it, then in the list settings in sharepoint designer (right mouse on list) set the newform property to point to the new copied custom form. This way you can alwys go back by just resetting the property in the list settings instead of getting the problems you have now.
Here's an in-depth explanation: WinSmarts article
As Colin mentioned, always make a copy. Of course, you can recover from deleting or corrupting your newform but it's a little bit of a pain. SharePoint's odd behaviour causes lots of people to do this... very often we create a new SharePoint form but the list refuses to use it as a replacement newform or editform so we delete the original.
Off of the top of my head, I believe you can copy the newform.aspx from another list or library and then update the GUIDs in the source view. Once you retrieve the file, however, you will have to complete 2 additional steps in order to get it to work. SharePoint requires a strange synergy between lists and libraries and their supporting pages. People are aware of the first, which is called Supporting Files, by right mouse keying on list you can choose supporting files for display, edit and new. What most people don't know is that these files, well actaully their components, must be "aware" of the fact that they are of type display, edit, or new. If they are not "aware" then any changes you make to "Supporting Files" will not stik.
To create a new page or update an existing one, locate your newly created or broken newform.aspx, if you are creating it from scratch go to Insert >> SharePoint Controlls >> Form Web Part... select the form web part of your choice and add it. Upon insertion view the properties of the form control andselect the radio button "NEW ITEM FORM". After you save the page you can then select the page as a supporting file for the list and the setting will stick.
The best options is as follows:
Simply delete the bad ListFormWebPart form page if it still exists
Make a copy of one of your good ListFormWebPart form page
Rename the copied ListFormWebPart form page to whatever the name of the bad one was
This works for New, Edit and Display and is the best option because it basically restores you back to the factory default OOB ListFormWebPart instead of creating DataFormWebParts, which have their pros and cons.
I have had to deal with corruption issues with Sharepoint so this is somewhat related.
Create a new list and using SPD, Copy the WebPartPages Section:
<WebPartPages:ListFormWebPart runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{203BDF1B-4980-4FEF-A4B5-C5A4C4A1BFA7}" >
...
</WebPartPages:ListFormWebPart>
Now in your list with the corrupt or missing form. Create a new form with SPD. Yes we know it's not the same. Bear with me.
In the WebPart Pages you copied from the donor list you need to replace the ID, webpartid, ListName id and, ListID from the new form you just created onto the save we pulled from the donor list.
On the Newform you just created. delete everything between and replace with the modified donor webpart you just modified.
Save and visit your new default form.
For what it is worth, I was able to recover.
Here is what I did. First, I mapped my Share to a Z drive.
Then, in SharePoint Designer, I renamed my list to list-bak.
Then, I created a new list of the original name (in SharePoint Designer).
Then, I updated the ListName GUID in the EditForm for the New List.
Next, in Command Prompt, I moved my dummy list to bak2, and moved by bak list back to the original name.
At this point, I had my EditForm restored, but it still wasn't working (as it was trying to reference the EditForm.aspx from the bak2 list).
Finally, I moved the EditForm.aspx from the bak2 to the original list, and was able to restore.
I hope this helps some other poor sap.
EDIT: to the OPs question, obviously you would do the same steps, but with NewForm instead of EditForm

Complex form design in Sharepoint

I'm trying to build a form for WSS 3.0 which has the following two characteristics:
Have several sub-records in each records which contains few specific fields.
Can export to HTML or something similar which can be viewed in every browser.
I realize (unless I'm mistaken) I can achieve 1 only by using InfoPath and RepeatingSection/RepeatingTable/etc.
As for 2, I see InfoPath is only capable for exporting to MHT/PDF/XLS, none ideal for me, since the goal is to create a something that can be published to the web.
Any hints about better way to achieve this?
Correction for 2: I meant that the InfoPath form should be editable within our intranet, but exported as a read-only-web-page for our web site. So I meant "exporting" and not "publishing".
One way to do this would be to use a database as the primary data source for your forms, so that all form data is saved there. You could then build a website that queries the database for all info.
Another alternative would be to take the infopath form data (saved as an xml file) and publish it on a web server with an XML Style Sheet to define its format. You could do this via an XML control in ASP.net.
These solutions might require more elbow grease than some other solution, but I believe either would work.
Perhaps creating a custom fieldtype is a possiblity. Create a fieldtype that has some kind of collection as value.
As for 2, I see InfoPath is only
capable for exporting to MHT/PDF/XLS,
none ideal for me, since the goal is
to create a something that can be
published to the web
That's not right, InfoPath forms can be published to the web. When publishing the form to the SharePoint via the InfoPath client, you can select an option saying that this form should be editable within a browser. But beware that some form features of InfoPath are not available when you do that.
Or do you have a different understanding of "can be published to the web"? For me it means, creating a new item in the library to which the InfoPath form is attached to --> Form is opened in the browser --> user fills in the form --> user klicks the save button --> info path document is saved to the library and closed.
Just an idea:
If InfoPath (along with MOSS) is not an option, then perhaps you could mimic its behaviour through a custom edit form, if you want the data to be outputted into a SP list. I'm thinking about a custom edit form with dynamic html controls (for the sub-records), and you can achieve this by dynamically inserting objects into the DOM as your tree structure requires. Then, on form submit, an event handler on the list would parse the data submitted by the form and store it as you see fit (in an xml serialized in a custom field, for example).
If it's not going the be a custom edit form for a list, then the same functionality above can be stored in a site page with code-behind (beware of customizations) and use a hidden SP list as your data storage.
As for the exporting section, perhaps an application page linked in the ECB menu of that list would get the above mentioned xml and display it nicely.

Resources