Validation based on Context

I have a form with two different input fields and two submit buttons. I would like the validation for the first input field to kick in if the first button is pressed and the validation for the second input field to kick in if the second button is pressed. But I don't want the validation for the second input field to be executed when the first button is pressed neither the validation for the first input field when the second button is pressed.
Is there an easy way to do this?
Martin

Hey Martin
I had the same issuse a while back and this is what I came up with.
on my jsp form I have the following commandlinks
<h:commandLink id="back" action="#{AppAction.test1}" >
<h:graphicImage value="/images/back.gif" style="border-width: 0"/>
</h:commandLink>
<h:inputText id="field1" value="#{testBean.field1}" </h:inputText>
<h:commandLink id="next" action="#{AppAction.test2}" >
<h:graphicImage value="/images/next.gif" style="border-width: 0"/>
</h:commandLink>
<h:inputText id="field2" value="#{testBean.field2}" </h:inputText>
public String test1(){
          FacesContext facesContext = FacesContext.getCurrentInstance();
          testBean test = (testBean)app.createValueBinding("#{testBean}").getValue(facesContext);
if(test.getField1().equals("Bad Answer")) // or you check for null or what ever
return("Error"); // direct the user to an error page if you want
else
return("Go To NExt Page"); // direct the use to the next page in
I hope this helps. I can go into more detail if need be. This may not be the best but this is
what I came up with.

Similar Messages

  • Setting validation based on condition on custom list

    Hi,
    I have a custom Image library. I have two custom columns created as part of metadata.
    One is a dropdown choice column, which contains 2 values - "Free", "Paid".
    I also have a datepicker column (date only). 
    I would like to set a validation based on below condition:
    If dropdown selected is "Paid", then date should be mandatory field.
    Can this be achieved OOB or a JSLink is required.
    How to achieve this?
    Thanks 

    Hi Vankatzeus,
    You can achieve this using Javascript. In New and edit forms of your list, add a content editor webpart with the script explained below -
    There is a PreSaveAction() function that you can use to do a custom validation. Before submitting any item, sharepoint first do the validation in PreSaveAction().
    function PreSaveAction() {
      //Step 1 - Read the choice and date fields. 
    // Step 2 - If choice is 'PAID' and 'date' field is blank { alert('Date can't be blank'); return false;} else {return true;}
    In Step 1, write a script that read values from choice and date fields. You can take the script from
    here and modify it just to read choice and date fields.
    Cheers,
    Manvir

  • Validation based on view attributes

    JDeveloper 11.1.1.x
    What is the best practice to create validations based on a view attribute from a view object that is of a level higher in the hierarchy?
    For example:
         * Use the departments and employees tables from the hr schema.
         * Create an EO for only the employees table, so not for the department table
         * Create VO's for both tables. You should create the Viewlink manually between both views.
         * In the query for the department, add a calculated field in the query.
         For example : availableSalary : 100000 - (select sum(salary) from employees where department_id = Departments.DEPARTMENT_ID) availableSalary
         * I would like to add a validation on the salary field of the employee EO, that says that the new value shouldn't be bigger then the availableSalary field
         Be aware : that when changing an existing salary, only the difference between the old and new salary should be taken into account
         (This removes the "Compare with View Object Attribute" possibility :-()
         * I also want to use some fields from the departments view in my error message on the salary field of the employees EO.
    How can we best tackle these requirements ?
    Thank you in advance.
    Filip Huysmans.

    Filip,
    I think you are trying to avoid the lesser cost of a Department Entity by an extremely expensive way to get to the comparison done. Firstly, you wire a view instance with an entity, which is strange as there is no association between the entity and the View Object. So all you would have is to access a method in the AM Impl method that looks up the VO and returns the current row's information you need. This AM method can be referenced from the entity object using groovy to perform the comparison (you see that even this is kind of awkward as it connects the entity to the AM, producing a tight coupling that makes any of your code reviewers shake heads in disbelieve). Assuming the update of the VO updates the entity (Departments EO you don't have), you could follow an association using Groovy to perform the validation (which I think sounds easier to do (though by the small cost of creating an EO)
    Btw.:
    if you have a ViewLink defined then the transient attribute can be easier calculated using Groovy
    10000 - DetailTargeName.sum('Salary');
    I would think its less expensive then running a SQL query for each department Id
    Frank

  • Validations based on Listing

    Hi Experts,
    We are developing a custom program to upload the Lower and Capacity values for the SKU's in a custom table for every store.
    While uploading the data, we want to put a validation based on the Listing, so that we can put a check while updating the table.
    The reason being, if a particular SKU is not listed for a Store, then we don't want that SKU be updated in the table ( for reduced table value maintenance).
    We are using Listing procedure B3 by default for all SKU's in the article master.
    But I am not sure, how to put a validation check here.
    Could you please help me in this scenario?
    Regards
    Nainar

    Hi Nainar,
    please have a look at function module WLK1_CHECK to integrate that in your custom program. But logic can a little bit difficult as listing conditions are time-dependent (e.g. no longer valid or valid in the future). So you have to decide how to react in which case.
    From your description, it is not clear how often you want to upload your data and how often listing changes occur, etc.
    Hope it helps.
    Regards
    Tobias

  • Validation based on conditions in another table

    Hi All,
    I'm trying to do a before update validation based on a condition. Basically, if the value of table1.columnA is changed to Yes only save when there are no rows in table2 columnX = Yes, otherwise online error.
    I have tried expressions, boolean, etc. and can't quite get the right combination.
    I am looking at something like select Y from dual where count of T2.CX = Yes is >1 otherwise N, and generate error only when Y is returned.
    Any help is appreciated.

    Thanks for the help. I did get it working, but in a way completely opposite than I was thinking it should work.
    FYI -
    The validation is expression 1 is contained in expression 2
    expression one is the p15_task_closed
    expression two is NO
    add a condition Exists (Sql returns a row)
    then do the select from the other table where it is true!
    I guess it says look at the conditions first, if the condition is true check the validation. If the validation is TRUE then no error, if the validation is FALSE (in this case the p15_task_closed = YES) enforce the validation error.

  • Field Validation based on SalesStage

    We have three Sales stages in the Picklist Opportunity Sales Stage, According to these Values one of below fields should be Mandatory. The values are as follows:
    If Sales Stage is
    1.     Closed/Won Then the Reason For Win(Text Field) Should be Mandatory
    2.     Closed/Loss Then the Reason For Loss(Text Field) Should be Mandatory
    3.     Closed/abandoned Then the Reason For abandoned(Text Field) Should be Mandatory.
    Could you please suggest me how to do this. Because we don’t have any field validations on Opportunity Salesstage(It’s a seede one), we can’t edit the things also. my thought’s are to place validation based on Sales stage id, i get the id from Source page and i am trying to validate on Reason for win field by using below query, but it is not working for me:
    IIf((FieldValue('<SalesStageId>')="AHIA-PS3GK" AND [<stReason_for_Win_ITAG>]IS NULL, "Invalid", [<stReason_for_Win_ITAG>])) and how to place combination of all the queries on SalesstageId field.
    Thanks
    Subbu

    Hi you can use another field for validation like Opportunity Name, but you have to mention that this approach only works if you insert a new record, not on update. To workaround this you can have another field that is mandatory and has the salesstages in it. Use a combination of default value and an update workflow for it...

  • Formatting based on context

    Hi can somebody help how you can set format in formatting sheet, which will be based on context? This is not working for me:
    Thank you very much
    Jozef

    Hi,
    You can meet your requirement using conditional formatting as below :
    Hope it helps..
    regards,
    Raju

  • How to Create a Validation based on a Z table

    I want to create a validation for t-code FB50 so that for any line item that contains a GL Account listed in a table, the validation would then check to see if the field Trading Partner is populated.
    My question is How do I set up the validation so that the values in the table are referenced?  I don't want to have to continually update the valid GL accounts in a set. I want the table to hold the values.  The business users have a custom t-code to update the values in the Z table.
    The Z table contains the field HKONT (GL Account).  The table contains 1 record (it could contain more) with GL Account 123456.
    My attempt was to create a set (Z_TP_ACCTS) that was based on the Z table and the corresponding field.  I then set up my validation to compare the value entered in FB50 (BSEG-HKONT) to look at the set.  My understanding is that the value would be compared to the values in the table, but my tests are failing.  I did not enter any values in the set.
    Any advice / help would be appreciated.

    Hi
    You will have to use an user exit to call up the Z Table to check for your requirement. There are lot of postings on SDN to use an user exit in FI Validations. The standard module pool provided by SAP is RGGBR000 for FI Validations. You can write a form in this.
    Additionally you also have the option of using a BTE for this. The one I can recollect are 00001011 or 00001085
    Thanks & Regards
    Sanil Bhandari

  • Mapping based upon context change

    Hi,
    Quick graphical mapping question:
    I have an inbound message with 2 contexts for one segment - <ClaimantInformation>
    Basically, I want to set the content of a target field based upon the following:
    If context1 of <ClaimantInformation> then set field1 to "A"
    If context2 of <ClaimantInformation> then set field to "B"
    I'm sure there must be an easy way to determine which context you are dealing with and set a target field accordingly.
    Any ideas ?
    Thanks
    Colin.

    Hi
    You can try writing a UDF ..
    take source as input to this UDF...
    In the UDF check whether it is context 1 or 2 by using counter in a loop....
    according return A or B

  • FlexField Validation based on Form Status

    Hi ,
    Background :
    I have a Valueset attahced to a segment in DFF, that say, stores a employee ID. My Value set picks up only active employees based on a specific condition. So that, when user enters data, he/she can choose only active ones.
    But as days pass by, the users are end dated. So when I query the Order ( to which this DFF is attached, ) that has an end-dated employee attached to it, the validation fails.
    My Question :
    Is there a way to have the Value set fire only in the Entry Mode and not fre in Query mode?
    Do we have to do this using the FORM.STATUS ( 'NEW','CHANGED') in the valueset query to acheive this? Or is there a simpler way?
    Thanks
    konnektme

    Hi Karthik,
    Instead of making the value set not to validate, you can make the value set to validate as successful. This can be achieved in any of the following ways.
    1) Make the Employee value set to display both Active/Inactive employees. If required the Status column can be displayed in the LOV. Also the list can be ordered by active employees first, then followed by inactive employees. There by user have the option to select the exployees be referring the employee status. This provides a provision to create records based on inactive employees also. If we strictly want to restirct to select only active employees. As said earlier, we can validate in Key-Commit or When validate Record.
    2) Change the value set to return active values always and inactive values only based on condition. Say the condition is (:system.record_status <> 'QUERY' and active_flag = 'y'). In this case only active records will be retreived in the record status is not query, where as if the record status is query, inactive records will also be retreived.
    If you have any solid condition to restrict the records, you can use those instead of record status/form status.
    I would prefer to use Option 1. Which will provide a solid result all the time. Where as option 2 might cause some issues if it is based on record/form status.
    Thanks
    K.Nataraja Suthan,

  • Help setting validation based on route selected

    If the LC form only has one submit button, how do you set a validation on submit based on the route selected when running forms in workspace?
    For example, if users have the option to Approve or Reject a form, can you determine which route they have selected and validate fields accordingly? So that if "reject" is selected we can validate that the reject comment field was completed, and if "approve" is selected we can validate that the form was signed?  Is there some property of the submit button or process field that makes this distiction?
    Thanks for your help!

    You can use a JavaScript if-else statement on the preSubmit event of the button. Do a check to see which of the fields are populated, then perform the required action.
    You could even hide the buttons, then if the user fills in a comment in the reject field, you simply show the reject button and keep the approve button hidden. You could have a pop-up when the form opens informing the user of the document's steps / process.

  • Hiding a line based on Context data

    In my form I am attempting to check my context data field for a value using Javascript and then I have a line in my form that I am trying to hide based on it.
    The Javascript is in the readyForm event of the "Signature" Subform.
    However, it is not working, Any ideas,

    hi  Mike Andries  
    try this javascript code 
    if(xfa.resolveNodes("xfa.record.LOGO[0]").item(0).value=="Y")
    Line1.presence = "hidden";
    hope it will help
    Jitendra

  • ZipCode validation based on locale

    Hello All.
    I'm currently developing an application and i kind of ran
    into some problems that i'm trying to find a possible solution.
    This app will be used for many users spread out into Europe, Asia
    and Americas and one requirement is to validate a given zipcode
    based on the user's locale.
    I've been trying to find examples on any possible web search
    engine that you could possible think of and no results so far.
    Please, if any examples/questions fell free to write me or
    reply to this topic, your help is greatly appreciated.
    Thanks
    Alvaro Costa
    Software Engineer
    [email protected]

    Here is a macro (sql function) we use for Canadian Postal
    Codes. Bear in mind that the data we receive does not have the
    normal space between the 3rd and 4th characters. The percentage
    sign represents the argument.
    returns Y or N to indicate whether postal code is valid CASE
    WHEN
    SUBSTR(%1,1,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','X','Y')A ND
    SUBSTR(%1,2,1)IN('0','1','2','3','4','5','6','7','
    8','9')AND
    SUBSTR(%1,3,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','W','X', 'Y','Z')AND
    SUBSTR(%1,4,1)IN('0','1','2','3
    ','4','5','6','7','8','9')AND
    SUBSTR(%1,5,1)IN('A','B','C','E','G','H','J','K','L','M','N','P','R','S','T','V','W','X', 'Y','Z')AND
    SUBSTR(%1,6,
    1)IN('0','1','2','3','4','5','6','7','8','9')THEN 'Y' ELSE
    'N' END

  • Generate output values based on contexts

    Queue 1 :
    contextchange
    mat_name1
    contextchange
    mat_name2
    contextchange
    mat_name3
    contextchange
    mat_name4
    contextchange
    Queue 2: ( output from Boolean AND)
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    false
    true
    contextchange
    Based on the 2 Queues, I shud get the following output :
    contextchange
    mat_name1
    contextchange ( based on 2 true values of the queue 2)
    mat_name2
    mat_name2
    contextchange ( based on 3 true values of Queue 2)
    mat_name3
    mat_name3
    mat_name3
    contextchange ( based on 1 true value of Queue 2)
    mat_name4       (because false ignore II ocurance)
    how do I achieve this?
    regards,
    nikhil.
    ***each useful reply will be awarded***

    Hi,
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    false
    true
    contextchange
    remove false from the above context. then ur output will be
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    true
    contextchange
    now u can use UseoneAsmany.
    chirag

  • Sql queries from internal tables based on context node

    Hi experts,
    I want to select from my inetrnal table which is based on the context node, the rows which do not appear in another internal table based on the context node.
    I have this data:
    data lt_item_level type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_item_level_cp type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_po_items TYPE table of wd_this->element_po_items INITIAL SIZE 0.
    I want to do this:
    select * into CORRESPONDING FIELDS OF TABLE lt_item_level_cp from lt_item_level WHERE lt_po_items-po_number NE lt_item_level-item_number.
    But i get an error:
    "LT_ITEM_LEVEL" is not defined in the ABAP Dictionary as a table,
    Is there a way to do it with select or should i loop over my internal tables?
    thank u very much!!

    hi,
    You cannot use Select queries on internal table.  do like this :
    loop at itab into wa where wa-F1 NE wa-F2.
    append wa to itab1.
    endloop.
    Here itab1 will have all the records as per your requiement.
    I hope it is clear.
    Edited by: Saurav Mago on Oct 26, 2009 5:37 PM

Maybe you are looking for

  • ACS 5.3 Radius authentication with ASA and DACL

    Hi, I am trying to do Radius authentication on the ACS 5.3 for VPN access (cisco client) using a downloadable ACL with AD identity Clients are connecting to an ASA 5510 with image asa843-K8.bin I followed the configuration example on the Cisco site,

  • Notifications no longer work with iPhone 6 and iOS 8

    i did a Restore from my iPhone 5, all Apps that I want Notifications from are set, I.e. The Associated Press, CNN , etc. but nothing but Mail Notification ever show up. How can I fix this?

  • Got screen went off and power won't come on

    The iPod accidentally bumped the table the screen went out black and I can't get the power on or charge it.  It already charged fully last night.

  • Windows phone screen stays black

    I have a Nokia Lumia 1520 that I got new about 3 months ago.  It has been working fine until this morning.  The screen suddenly went black and won't come on.  The windows start button, back button, and search button light up, but the rest of it stays

  • Ichat webcam quality

    whenever i videochat with someone (even with a mac) the quality *****. Like crazy. Can I raise the quality of the webcam?