h:commandLink behaviour in jsf 1.2 - jsf-1.2

I have 2 commandLink in my page. A user has to fill in the details in the input text box (I have used h:inputText for this and all fields are mandatory), and click on "Submit". If a user dont wish to fill in any of these fields there is a link provided below Submit for "Skipping this activitiy" . This skip link will redirect to some other page. Both Submit link and Skip link are h:commandLink. I cant use h:outputLink for Skip because when user clicks on Skip I want to call bean and do some business checks.
Now, when a user doesn't fill in any of the details in the fields, but instead clicks on Skip link, the required=true attribute of h:inputText is getting fired. I want this to get fired only when user clicks on Submit without filling in any details and not when he clicks on Skip link.
How to achieve this?

Add immediate="true" to the commandLink.
It will make sure that all the input fields where immediate="true" hasn't been defined will be skipped in processing and no validation error will trigger.

Related

Marketo Forms2: How to track source

I can track the source of a lead doing go.example.com/?src='ThisSite' . What I don't know is how to track a form2 that was embedded and I don't find any information. Does anybody know how to do that? thanks!
To accomplish this, you will need to create a hidden field in your form that is auto-populated with the value of the referring page. Here's how to do this in Marketo:
Log in to Marketo
Under Marketing Activities, select your form and click Edit Form
Create a new field
Change the field type for the field you created to hidden
Select the option for Autofill
After the clicking option for Autofill, set Get Value From to Referrer Parameter.
Enter the Parameter Name which you want to get from the referrer URL and click SAVE.
Click Finish
Click Approve and Close

ASP.NET - RequiredFieldValidator to validate only particular controls

I have a web form. There are many different sections. I can say that each section displays data of a datatable. At each section I have OK and Cancel buttons. When I press OK any changes to the table in the database takes place. I've also put some Requiredfieldvalidators. Let's say I'm inserting a new record in the section one and the fields are correctly typed. When I press OK I get error message raised by the rest of the validators that are on the other sections. Isn't there any way that when I press OK button of a particular section to get validation errors of that same area? So what I probably need is a button that will not serve as the hole page submitter but rather a submitter of a specific section.
Place a ValidationGroup on the RequiredFieldValidator's. Then place the same ValidationGroup on the correct submit button. When its clicked, only validation controls that are a part of the group are validated.
http://msdn.microsoft.com/en-us/library/ms227424.aspx
I think janhartmann is correct ValidationGroup can help you solve the issue.Have a look at this article

Drupal save data hook_form_alter

I added a field to a node using hook_form_alter and i can see it fine but now i would like of course that the data enterd in that field is also saved. What do i have to do for this to happen?
When you alter the form, you need to also add a form submission handler to the module; in that way, your module would be invoked when the form is being submitted, and you can save the value of the field you added.
If there are more than one button, then it's preferable to add the submission handler to the specific button you need to act upon. Suppose, for example, that the form has two submission buttons: "Save" and "Delete"; if you add the submission handler with $form[#submit][] = "my module_form_submit"; then the submission handler is called even when the "Delete" button is clicked.
As reported in Form buttons can define custom #submit and #validate handlers:
All forms can have "#validate" and "#submit" properties containing lists of validation and submission handlers to be executed when a user submits data. Previously, if a form featured multiple submission buttons to initiate different actions (updating a record versus deleting, for example), it was necessary to check the incoming $form_values['op'] for the name of the clicked button, then execute different code based on its value.
Now, it is possible to define #validate and #submit properties on each individual form button if desired.
When a specific button is used to submit a form, its validation and submission handlers will be used rather than the default form-level ones. If none are specified at the button level, the form-level handlers will be used instead.
Additionally, The 'op' element in the form values is deprecated and should not be relied upon reports:
As discussed above, each button can have "#validate" and "#submit" functions associated with it. Thus, there should be one button that submits the form and which invokes the normal $form_id_validate and $form_id_submit handlers. Any additional buttons which need to invoke different validate or submit functionality should have button-specific functions. Note also that the 'op' element in the form values, corresponding to the button clicked when there are several in a form in Drupal 5.x, should no longer be relied upon and may not be present.

User Control is not posting its form values

I have a user control I am adding dynamically.
It has a link button and a text area on it. The containing div is hidden via style sheet (client side), and I use some jquery to pop it up in a modal.
It is getting added in the init and the button click event is firing on the server.
BUT the textareas value is not being set. On further inspection the field value is not even being sent in the form POST data.
Any ideas why the value is not being sent. The rest of the form values are being sent with no problems.
Make sure the control is actually being added to a form control. Your link button will still post back even if it's outside the form as it's a javascript call, but there won't be any content from your server controls in postdata.

ASP.NET validation

I have a little problem with the validation in one form
the form is composed by two taqs. There is a "Save" button in each tap (is the same control for both) and saves the form info. there are validation controls in one tab but not in the second. When we try to save the info from the second tab, and the info has not been filled in the first tab, the validators fire, and nothing happends, but because this validators are shown in the other tab, the end user might be thinking that the operation has been completed, instead, I would like to show a msgBox telling the user about the errors in the other tab. How do I know that the validators in the other tab have been fired, and display the error message when the button is clicked?
You should use the ValidationGroup of your validator controls and the appropriate submit button. You can also use a ValidationSummary control which displays a summary of the validation messages - this can be set to display a message box if you want by setting the property ShowMessageBox=true.
taqs - tap
dear why are you so confused?
All the validators are posted to the page as JavaScript functions. You can call the validation function on button's click and take the appropriate action.
You can use on buttons
onClientClick="Page_ClientValidate();"

Resources