Hide Facet in Design for better styling of design definition - xpages

I am currently designing my design definition to give the users of my custom controls an idea of what the xpage will look like. The only problem i have in the design panel is that even though a facet is filled with controls i can still see its name. That screws up every design coming from my design definition.
Is there a way to hide the name of the facet once controls are assigned?

Related

Dynamically add / remove editable area to custom control embedded in XPage

Okay... this is a little difficult to explain but I will try my best.
In Custom Control while adding properties in Property Definition we can set "Allow multiple instances" which allows us to add multiple instances of that property when the control is embedded in XPage.
Similarly, I need to know whether it is possible to add (and remove) Editable Areas in a custom control when it is embedded in XPage? What I plan is that I would have a repeat control inside my custom control and I would be able to put the contents in each editable area in every loop of that repeat.
Is this the right way to go about or am I looking at this problem incorrectly? Any solution not involving editable areas is also welcome :)
Update 4 Apr 2013:
A use case context I am looking for is a simple carousel where contents of each screen in carousel can have different contents. These contents would be put into each (dynamically added) editable area. The contents can be very different from each other with one screen containing only text, other only image and another both image and text.
Look at the table walker example in the 26 original exercises. It does mostly what you are looking for (conceptually). You won't need multiple editable areas. Whatever is inside the repeat gets repeated.
What you want to do is to give the control a custom property "boolean editMode" so you can render that one line to be edited - if that's the UI pattern you want to follow.
You also could consider a dojo table with Ajax which allows for a familiar spreadsheet UI

Can you compute which custom control to use?

Think "computed subform", but in Xpages.
On one of my custom controls, depending on a certain value, I want to either present a custom control that renders a drop-down list using a combobox or renders an input box with a type-ahead.
This is on a custom control that renders a view, with all view configuration choices handled by a document rather than design, so several different views utilize the same custom control.
For example: I have a By Status view using the custom control that has status as the first column and we use a combobox to allow the user to select which Status value to filter by. Another view is sorted by Requisition number and I want to use a type-ahead instead of the combobox.
My preference is to use the same dynamic view custom control for both and have a formula that determines which of the two (comboBox or inputText) to use. How do I compute which custom control to load?
(Credit for the dynamic view control goes to Scott Good's folks over at Teamworks Solutions.)
During it's life cycle, an XPage exists in two places. First of all a representation of the XPage's relevant components is stored on the server. Then the page goes through a lifecycle, retrieving properties from documents, checking which components should be rendered, retrieving the data for any repeating control such as a View Panel etc., and passing the relevant HTML to the browser. The browser is the second place it exists.
So you can't compute a custom control as such. All you can do is set the loaded property, and loaded needs to be based on a non-dynamic calculation such as a viewScope variable, the current XPage name, a view name stored on the XPage etc. What you would have difficulty doing would be using a different custom control based on data on that row entry.
The other option is the Dynamic Content control or Switch control from the Extension Library. Both are similar to using the loaded property, in that you're putting both custom controls on the page and choosing which to display.
From what you're describing, the loaded property should cover what you need.
Some time back I saw this question on StackOverflow where the author had used Include Page control (xp:include) to include custom controls using pageName attribute based on formula.
<xp:include>
<xp:this.pageName><![CDATA[${javascript:sessionScope.ccPageName + ".xsp";}]]> </xp:this.pageName>
</xp:include>
Similar to the technique described by Paul Withers in his answer the attribute of pageName is also computed on page load.

Is it possible to determine the facet content in a custom controls design definition?

I'm putting together the design definition for a custom control and would like to vary how it displays based on whether or not a different custom control has been placed in the one of the facet areas. Is this possibe with the design definition and if so, how?
I know I can reference properties of the custom control by using "this", but I couldn't guess as to how to get to the facet content information.
Any ideas? Thanks
In the design definition you can add a callback node where your facet should appear. This should expose the Editable Area when you add your control to another page.
The format for the callback node would look similar to
<xp:callback id="callbackID" facetName="facetname" />
Dan,
Can you get the Editable Area as a javax.faces.component.UIComponent and then do .getFacets()?
BTW, hope you're well!

Design-time support on composite control

I'm creating a specific DataGridView control that includes two scrollbars so that I can control their size and visibility. So, I have created a User control that contains the DataGridView and the two scrollbars inside a 2x2 TableLayoutPanel.
The issue I'm facing is that when I add my control to a Windows Form, I can't set my DataGridView's DataSource or define the column styles from the design view, because the link that I use for that when I use a common DataGridView (that little white arrow appearing on the top right side of the DataGridView) is not appearing.
While doing some testing, I saw that if I inherit my control from DataGridView, that link appears. But if I do that, I guess that I can only extend the functionality for the DataGridView, but I need my control to be a composite control.
So, that's my question: how can I get those design-time capabilities on my custom control? I am specially interested on the columns layout and the datasource.
Best regards.
If you are doing a usercontrol (a control that has an .ascx codebehind file) there seems to be no way to control this:
How to hide the inner controls of a UserControl in the Designer?
If you are doing a WebControl (a class that inehrits from WebControl with no .ascx file) you may create your own designer and maybe somehow output the designers of both conrols. Have a look at: http://msdn.microsoft.com/en-us/library/12yydcke.aspx it explains how to create a webcontrol and its desgner.
Some things with usercontrols/webcontrols seem to be easy but are hard to implement...
Hope this helps!

User controls as "screens" in a webpart

I'm workin on my first webpart.
I use some number of user controls as screens. And I have a trouble here.
First screen contains a list of dynamically created options (hyperlinks). After user made a decision with click, I want to change the screen and pass to the new screen some parameters.
My dicision is to load all controls I need on webpart creation. Controls I don't need right now I make invisible.
SomeUserControl1 uc1 = (SomeUserControl1)Page.LoadControl("~/_controltemplates/SomeUserControl1.ascx");
SomeUserControl2 uc2 = (SomeUserControl2)Page.LoadControl("~/_controltemplates/SomeUserControl2.ascx");
uc2.Visible = false;
Controls.Add(uc1);
Controls.Add(uc2);
Option in first user control realized as LinkButtons (serverside). OnClik event calls a special method in the webpart class and in this method i change a visibility of my user controls and pass some parameters to usercontrol2.
I don't like this approach. Are there different ways to realize described functionality?
Thanks!
You need use a ASP.NET Wizard Control, it does what you exactly you want.
From a design standpoint what you are doing looks a little bit frightening. You should think about nesting the various user controls into a single user control that you can use as the face of your webpart. Keep the coupling between the various user controls loose and think about implementing the Observer pattern if you need to do things like playing with control visibility.

Resources