I have a collection of some items. Using * symbol I set user control (ascx) in presentation details for all of them. Now I have a problem because on of this items has to be display in another control. Is there some trick that allow me to change used control dynamically, for example checking url segment?
I'm guessing you're using wildcard item called * with some presentation details defined on it. And now you want to display different components for one you the urls?
If you want to have completely different presentation, you can add another item as a sibling of the * item and put new presentation detail there. This item will be matched before the wildcard item, if the url segment is equal to this item name.
If you want to change only one or few components, you can use personalization for this component and where the item name compares to ... rule.
Marek's answer is preferable, but for completeness I will provide another potential option.
It depends on how you are handling the wildcards. I don't think it will work if you are using the wildcard item module from the Marketplace and it might not play well with some of your existing code, but here goes...
You could place the required presentation details on the target items themselves. Then when you resolve the wildcard, you would need to change the context item to be selected target item. When the page loads, it will use the presentation of the newly set context item.
One way to achieve this would be to create a custom item resolver
class WildCardItemResolver : ItemResolver
{
public override Process(HttpRequestArgsargs args)
{
base.Process(args);
// if Context.Item is as wildcard
// look up the target item
Context.Item = targetItem
}
}
Related
I am newbie to the Alfresco.Now my requirement is how to add new menu[All(All pages)] in Select. wherever user perform search function lets say 250 results have found & user selects All in page 1 & its selecting only current page results and not selecting entire 250 records & then user goes page by page can edit the properties for the entire 250 records.in the new functionality if user selects [All(All pages)] then all records should be selected & edit the properties for 250 records at one go.So I want to add new menu with All(All pages) & change the existing menu current labels as All(Current Page).How to achieve this functionality and what files need to changed.How should i know that which files are currently used?Is there any debugger can be used to know the files?
Alfresco Version
4.2.e
My guess, is that if you go through this previous version of Jeff Potts' Tutorial you will be able to figure this out by yourself.
Simplest option is to edit label of that particular action in out of box property file.
You can find it under
<ALF_HOME>\tomcat\webapps\share\WEB-INF\classes\alfresco\messages\slingshot.properties
This entry
menu.select.all=All
Change label here and it will be reflected.
NOTE: It is not best way to implement this. Ideally you need to override property file and change label
The issue here is that only the items shown on the page have been loaded. This means that the metadata for the items not shown on the page won't be available. The metadata of each node is used to evaluate it's applicability to any action. If the node is locked or has had its permissions changed then it won't be possible to edit it. This is why "all" only means all items on the current page of data.
I'm creating a new unordered list as follows:
Using htmlUL As New HtmlGenericControl("ul")
End Using
Before closing the 'Using' clause, the list has to be added in a parent control:
Using htmlUL As New HtmlGenericControl("ul")
'Some Code Here
parent1.Controls.Add(htmlUl)
End Using
Everything works fine until i add my control to more parents :
Using htmlUL As New HtmlGenericControl("ul")
'Some Code Here
parent1.Controls.Add(htmlUl)
parent2.Controls.Add(htmlUl) '<--- Only gets added in the last parent's collection
End Using
This behaviour is expected because every control is unique. But i need to add this list to more than one parents (it does not include any static ids in order to avoid conflicts)
ASP.NET does not support scenario like the very same control object used in several places. The reason here I believe is the problem with identification of the control later in the page life cycle - this control would have to render under different parents, and with different IDs, etc. Looks like a very complicated and dangerous use case.
However there are several workarounds written here and there to clone controls on the page. For example checkout these threads: Copy/Clone Control, A Custom Copy Control - Copies Any ASP.NET Control.
All that beign said, in your case the easiest thing is just to create new list for each parent control. You do not need to copy any specific properties or data whatsoever, so no need for cloning overhead done in the solutions above.
I have this form with ~170 individual text boxes with values in a session scoped bean. There is a requirement to only submit values when the component has a certain CSS class.
The way I originally approached this was to create a PhaseListener at the UPDATE_MODEL_VALUES and test the CSS class there. If the class was the affected class I set the value of the component to null. Then on the front end, I switched the class on focus using a generic JavaScript method. This meant in terms of changes to each componenet I only needed to add:
... styleClass="examfieldgrey" onfocus="whiteField(this);"
which is kind of nice given how many components I need to change.
This was working fine until I re-factored my e form to use multiple h form tags. Now the CSSclass is switching on the front end, but this change is not being saved. The phase listener is getting the old class.
I'm thinking this is obviously related to me switching the class in jQuery/javascript. What I am wondering is:
Is there a better way to do this arachatectually? One that preferably means I don't have to modify 170+ componenets?
If I do have to continue with using Javascript to switch the class, is there a way I can post that change back from javascript?
Sorry if this is an obvious question, I'm still a little green with the JSF lifecycle.
I'm using JSF 2.0 MyFaces
For reference here is an example of a component on my form that needs to be filtered:
<h:inputTextarea
id="inputVal"
styleClass="midTextArea examfieldgrey"
onfocus="whiteField(this);"
value="#{bean.form.val}"/>
where "examfieldgrey" is the class I test for when determining if I'm going to block a component.
And the whiteField method:
function whiteField(field){
if(! jQuery(field).hasClass("examfieldgrey")){
return;
}
jQuery(field).removeClass("examfieldgrey");
jQuery(field).addClass("examfieldwhite");
}
And my phase listener before phase method where I filter:
// TODO: make whatever mode allows ghosting to be configurable outside of
// the system (perhaps in the config file)
/**
* Before the model is updated, test each component's CSS on the form. If the
* CSS style is 'examfieldgrey' set the value to null so it doesn't get submitted
*/
#Override
public void beforePhase(PhaseEvent arg0) {
//We need the session to get the backing bean
if (arg0.getFacesContext().getExternalContext().getSessionMap() == null) {
return;
}
//get the measurements bean so we can determine the form mode
if (arg0.getFacesContext().getExternalContext().getSessionMap()
.get("measurements") == null) {
return;
}
//ensure the bean is the expected data type, it should always be this type. I'm just paranoid ;)
if (!(arg0.getFacesContext().getExternalContext().getSessionMap()
.get("measurements") instanceof MeasurementsController)) {
return;
}
//get, convert and check the backing bean's mode. We only filter if the mode is COPY
if (((MeasurementsController) arg0.getFacesContext()
.getExternalContext().getSessionMap().get("measurements"))
.getMode() != FormMode.COPY) {
return;
}
//recursivly traverse the componenets and filter the ones who have the CSS class
traverseChildren(arg0.getFacesContext().getViewRoot().getChildren());
}
/**
* Traverse a List of UIComponenets and check the CSS. If it's the 'examfieldgrey' class
* and the component is a UIInput component, set the value to null.
* #param children a List of the componenets to filter on the form.
*/
private void traverseChildren(List<UIComponent> children) {
debugLevelCount++;
if (children == null || children.size() == 0) {
debugLevelCount--;
return;
}
for (UIComponent component : children) {
if (component instanceof UIInput) {
if (component.getAttributes() != null
&& component.getAttributes().get("styleClass") != null
&& component.getAttributes().get("styleClass")
.toString().contains("examfieldgrey")) {
((UIInput) component).setValue(null);
} else {
debugPrintAllow(component);
}
continue;
}
traverseChildren(component.getChildren());
}
debugLevelCount--;
}
Ignore the print functions, they don't do anything ;)
Thanks guys!
Edit
This is a copy operation so the backing bean has values in it after construction of the bean. The option of using the primefaces selector is great if I hit submit and the backing bean is not already populated. But I'm not sure if it will be able to actually clear out those values.
One other thing to note is that I am referencing values inside an instance of my form object. I don't know if that helps but it wasn't present in my original post.
There is a requirement to only submit values when the component has a certain CSS class.
If you happen to use PrimeFaces already or are open to use it, since the latest 3.3 version you can use the new #() selector syntax which accepts jQuery based CSS selectors in process and update attributes of PrimeFaces ajax components (which are equivalent to execute and render attributes of JSF standard <f:ajax> component).
For example
<p:commandButton ... process="#(.foo)" />
or
<p:ajax ... process="#(.foo)" />
will instruct JSF to process only the HTML input elements having classname of foo.
Now the CSSclass is switching on the front end, but this change is not being saved. The phase listener is getting the old class.
That's because you didn't keep JSF component tree in the server side in sync with the HTML DOM tree in the client side. You're making changes in the client side only without notifying JSF about this. CSS classes are not been sent as a request parameter to the server side, only the HTML form input values are. You basically need to change the CSS classes by JSF instead of by JS/jQuery so that the change is also reflected in the JSF component tree.
Implementing this is however not exactly trivial and potentially wasteful. Easiest is thus to use PrimeFaces with its #() selector support. This selector is evaluated in the client side and converted to a string of JSF-understandable component client IDs matching the selector. This thus takes client side changes fully into account.
I was able to get this one solved by creating a map of boolean values for each field on the form with string keys that are the ids of the fields. Each value represented weather or not to copy the field. I update this value using ajax on blur. And I set the CSS class to be based on the boolean value in the map for that field.
Rendering didn't work out so well. Originally I was doing this all on focus but it quickly became apparent that attempting to rendering a textbox on focus would actually lose focus to the textbox. So, on focus I just call a quick js function to switch the class as I had been doing originally.
Since the css class is chosen based on the map on the front end, it gets updated before the phase listener is called and the components get filtered properly.
Thanks for the help BalusC!
On the "services" and "company" pages I have a right sidebar list. This is being included with PHP. So far I have a CSS class for normal and a CSS class for when you hover each item in the list. I want to have a new class for when each list item is selected. So for example in services, the user clicks on "family planning" and when they get to the family planning page....the family planning list item has a grey background. Is this possible?
http://beulahprint.ie/index.php
Cheers,
Colm
Nothing in CSS will let you match an element based on it's href attribute resolving to the current URL.
Add a class to the menu item (or the body element) server side based on the page, then use a write a selector to match that.
There are a few ways to accomplish this but you'll need a little bit of code. It works like follows:
On your page you should somehow declare which page it is (by using a querystring or session)
Then you should parse this value and write out the class name of the menu dynamiclly.
Yes it is possible, when rendering the sidebar/menu, check if they are in a specific page/namespace and add a class to it which has grey background.
The general design people use for such scenarios is to place all items related to one menu item in one namespace.
like all admin items will be under */admin/*, so that when rendering the menu, they will check the url and add the class to it.
I have a form that is written in MXML that allows a user to create/add a User.
I need to add a form that allows a user to modify SOME but NOT ALL of the fields for this user.
The forms are so similar, I don't want to have to create two separate forms, one for Add and one for Modify.
For example, in the Add form, the user specifies a user id. In the Modify form, the "user id" field is not editable.
I'm wondering how I can initialize the MXML form (i.e. pass in a parameter?) so that it knows whether it is in the Add state or the Modif state.
I know I can't do the following but this is what I would like to do (pseudocode):
if (ADD_FORM) {
mx:TextInput id="txtUserID"
}
else {
mx:Label id="lblUserID"
}
This kind of thing is handled well with states. In Flex 3 you define your states like view, add, and edit. Then you can add the components that are common to all states to the document. Within each state declaration, you can then add the components that are specific to only some states. You can have the edit state dependent on add state since edit is add plus a few more fields.
In Flex 4 this is even easier. You declare your states, and then inline in the single document have all content for all states, with includeIn attributes for which states each element should be included in (or excludeIn).