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).
Related
I am trying to create a trigger for a particular form. What is the correct way to refer to form if i have no id?
Untested, but you should be able to create a DOM type variable, change the selection method from the default "id" to "CSS selector" and use that to address the form in question:
The actual selector might need a bit tweaking (and obviously you'd want to substitute the real name of the form in the square brackets), but basically that is the way to go.
You then create a form submit trigger, set it to "fire on some forms" and use the variable created above to filter the trigger for that specific form.
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
}
}
I have a content type with an entity reference field referencing to a custom entity. I need to use a select box because an autocomplete widget is not suitable in my case. However, I cannot load all the entities at once as selectable values because they are too many (72000+ the form won't even load). So I default the entity reference select box to a limited number of values using a views filter and then hide it by default. Then I use an ajax dependent dropdown to show and populate the entity reference select box with filtered down values (I'm using a module that implements hook_form_alter).
My problem is that the form won't validate because now I can select entity reference values which are not the default ones in the select box. So I guess I should control in some way the validation rules of the entity reference field. Is there an easy way to do this? Which hook should I use?
Set the entity reference field to autocomplete and take it out of the process entirely in your form alter with $form['field_entity_ref']['#access'] = FALSE. This should fix the validation problem. (of course, "field_entity_ref" is what I'm calling your actual reference field.
Add your own validation to the form, if that is still necessary.
Finally, implement hook_node_presave() to manually put the value of your custom ajax drop down box.
So if your custom ajax select box was named my_custom_ref, then it would look something like this:
function mymodule_node_presave($node) {
if (isset($node->my_custom_ref)) {
$node->field_entity_ref[$node->language][0]['target_id'] = $node->my_custom_ref;
}
}
i want to use validation on multiple component.In the form there are three h:selectOneMenu components and some h:inputText components. on change of first h:selectOneMenu i need to change content of second without validating other fields.Here i have use immediate="true".
Similarly for second h:selectOneMenu components onchanging need to change content of third SelectList here to i want to skip validation for others and i used immediate=true for this component too. Problem is" immediate= true and FacesContext.getCurrentInstance().renderResponse()" work for nonImediate components only.but as there are two component with immediate=true , on changing first Select one error is shown on second SelectOne list.Do anyone have any idea about this ?
Thanks in advanced.
I am using JSF 1.2
On selecting first h:selectOneMenu you can use value change listener in which you can do your stuff in the bean and can change the content of the second h:selectOneMenu.You need to re render this component. This way your immediate="true" part will be eliminated from the
So now you can put just one immediate="true" in the page and you can do your valdiation only on one field.
If re rendering and value change listener is not what you want to use, then you can put the first immediate="true" component inside the first form and second immediate="true" inside another form.
This way since both the forms are different your validation in both the cases will run only when that particular form is submitted or processed.
I know this is probably a very simple question, but can someone please walk me through how to take what a user inputs into a s:TextInput and use that as a variable in a JSON data request?
Basically, I want to have a user enter a search term, like "math" and then have that placed into a variable so I can use it in a JSON request.
Something like public var q:String, except that my search box (and hence user input) is on another "view" of the application.
I've just started with Flex Mobile applications and I might be way out of my league. Does anyone know how to do this?
The containing view should still be able to access teh child view's properties (and therefore controls); you just need the control(s) to have a unique ID, which then becomes a property name. That said, I would consider the whole search feature to be self-contained, so it'd have its own controller (action script class for handling actions) wired up to the search button, adn have a reference to the view that it can extract the info from, etc.