Input validation in datatable

Hi all,
I have a datatable displaying some records and allowing for each record to press a link to to something with that line. I am however facing problems with the field validation. Here's what I have:
<t:dataTable style="width: 100%" id="tfopts" binding="#{quoteOptions.freeFormOptionTable}" value="#{quoteOptions.unselectedFreeFormOptions}" var="option">
     <t:column width="70%">
          <h:inputText style="width: 98%" value="#{option.description}" />
     </t:column>
     <t:column style="white-space:nowrap" width="15%">
          <h:inputText style="width: 100%" value="#{option.catalogPrice}">
               <f:convertNumber/>
          </h:inputText>
     </t:column>
     <t:column style="white-space:nowrap" width="15%">
          <a4j:commandLink action="#{quoteOptions.addFreeFormOption}" value="#{msg.options_addoption}" reRender="selopts,tfopts" />
     </t:column>
</t:dataTable>Now, I need to make sure that the description is not empty when hitting the commandLink. I have tried by setting the required attribute, but then it's set for all rows, which I do not want.
Alternatively I approached it via Javascript, but it occurred to me that I don't know the id of the field on the row where the commandlink is clicked.
Can anyone help me out with this?
Thanks

tombatore wrote:
Now, I need to make sure that the description is not empty when hitting the commandLink. I have tried by setting the required attribute, but then it's set for all rows, which I do not want.This should work:required="#{!empty param['formId:dataTableId:rowId:commandLinkId']}"The 'rowId' part can be obtained from UIData#getRowIndex().
Alternatively I approached it via Javascript, but it occurred to me that I don't know the id of the field on the row where the commandlink is clicked.Make use of the 'this' reference and pass the commandlink element itself as argument to the JS function.
onclick="foo(this)"
function foo(element) {
    var id = element.id;
    // You can do substring and/or replace here and then get element by id from document.
}

Similar Messages

  • Input validation in an OO-friendly fashion

    Okay, so "input validation" may sound a bit like an issue for the security division of the forum, but I'm concerned with the most OO way to verify the inputs of users. The situation is that I have about five or six different blanks in a GUI (not that it matters) where a user can input something to change the GUI's model. The GUI's model is, itself, an interface and therefore supports pluggability.
    Now, each of the inputs has potentially different "policies" or business rules for what can be entered. For example, one may be a date, etc. You guys know what I mean. Anyway, I know that I could just have some validation method for every field, but this doesn't seem to be very OO-esque.
    I'd like to have some kind of an interface called "StringValidator" or something that would have a method "validate()," but I don't know how this would play out. Maybe I could have a map in my GUI model where the key is the field name and the associated value is an appropriate implementation of StringValidator? I don't know, though. Even though it would be easier to implement five specific methods, one for each field, I'd rather not.
    If I use some kind of StringValidator, maybe I could require a method that returns an array of Strings with all illegal forms, but then again, that's bad form...
    I really just don't know.
    So, in summary, my two questions are as follows:
    1. What is the best way to implement an OO, easily scalable way to validate Strings in my app?
    2. How do I protect against things like SQL statements, HTML scripts, etc.? I know I should (in many cases), but I don't know how to.
    Thanks for any help, and for wading through that description.
    theAmerican
    PS I just remembered something about some Scanner class or something. Maybe that would help?

    It depends quite what you're doing; if you're working with a db then using prepared statements would handle all the escaping for you, but if you allow the users to input raw SQL then you can't realistically stop them from screwing things up.
    Similarly if you're having the users create html somewhere, then the more flexibility there is the harder it is to control. You don't have to worry about scripting if you're just using JLabel to render the html as it doesn't support it; if you're creating a web UI then you may have to.
    Pete

  • MM41/MM42/(MM43) - Sales view: How to add own input validation for CALP-END

    Hello.
    I am looking for an easy way, if any to create an own input validation for a certain field in the article master on the sales view tab. In addition to any standard input validation I would a like to add an own validation (for CALP-ENDPR) depending on the input.
    How can that be achieved in the easiest and proper manner - in general and for the specific case?
    There are no screen exits etc. here, if I am correct.
    Any ideas?
    Thanks.
    C.N.

    Hi,
    Please refer the below link.
    This is for MM01. I understand that you are into Retail system. Hope the same processing logic can be done in your scenario also.
    saptechnical(dot)com(slash)Tutorials(slash)ExitsBADIs(slash)MM(slash)MM01(dot)htm
    Replace the bracket words with the correct symbols.
    With Regards,
    Sumodh.P

  • Input validations using bsp code

    hai all,
       i want to check user input whether he/she entered correct values r not, i know how to do using javascript.
    but i need to do the same without using javascript.. is there any way
    leoiz

    No, this was not a joke, but it would be possible theoretically.
    Doing a quick search on Google got me this nice link:
    http://www.permadi.com/tutorial/flashjscommand/
    It shows an example of Flash interacting with JavaScript, hence proving the possibility.
    As for really using Flash/ActionScript for input validation ...
    If you are thinking about just including a little Flash-Validation for input fields - why do it with Flash if you can use JavaScript?
    And if your page is a Flash-Page anyway, well, you would not have to go back to HTML input fields, as you work within your Flash applet.
    Maybe you have a specific situation I didn't think of yet.
    Max

  • How do I return to the top of a form when input validation fails?

    I have a form that I am using spry input validation that I
    would like the user to be returned to the top of the page when
    validation fails. If that can't be done somewhat easily, can I have
    a message appear next to the submit button that says "Errors found.
    The field(s) marked in red need to be corrected" when there are any
    errors that prevent the form from submitting.

    The break statement in Java is similar to last in Perl.
    The continue statement in Java is similar to next in Perl.

  • [solved][C] input validation with strtod()

    I'm using strtod() in an RPN implementation, and I'm working on input validation. As per strtod(3), I've written the following conditional to catch input overflow.
    errno = 0;
    op1 = strtod(token, &endPtr);
    if ((errno == ERANGE && (op1 == HUGE_VALF || op1 == HUGE_VALL)) || (errno != 0 && op1 == 0)) {
    printf("Error: Input overflow.\n");
    clearstack();
    return 1;
    Except that when I enter something that would definitely overflow, this conditional is never entered. Furthermore, errno is never set. What am I missing?
    A link to the full code can be found here
    Last edited by falconindy (2010-04-13 17:49:15)

    tavianator wrote:
    Well the first wrong thing I see is that you should really test if fabs(op1) is HUGE_VAL{F,L}.
    The second thing is, why so complicated a test?  errno != 0 should be all you need.
    Fair enough. This is the first time I'm really dealing with floating point ops in C.
    tavianator wrote:The third thing is, if errno is really not being set, are you sure you're really overflowing?  doubles go up to about
    1.8e308 on most arches.
    Huh... wouldn't an unsigned double be, at most, 2^128 - 1 and more likely 2^64 - 1? I'm dealing with signed, so its then half that. Sure enough, sizeof(double) returns 8.
    Also, this is what made me think I'm hitting overflow.
    > 111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1 *
    = 111111111111111105547424803279259724863245197668615715838829352563602489955831513088.000
    >
    Hmm. If I go even further, I eventually do hit an overflow error. However, that still leaves me a little baffled as to the results above. Is this a result of the decimal precision inherent in a double?

  • Element Input Validation - Table Values

    Hi All,
    Forum newbie.
    Can anyone tell me if its possible to do an Element Input Validation that is using table values?
    eg.
    This was my thinking -
    DEFAULT FOR TableLower IS 0
    DEFAULT FOR TableUpper IS 0
    INPUTS ARE entry_value (text)
    entry = TO_NUM(entry_value)
    Lower = TO_NUM(GET_TABLE_VALUE('Table Selected', 'Level', TableLower))
    Upper = TO_NUM(GET_TABLE_VALUE('Table Selected', 'Level', TableUpper))
    IF entry > Upper OR entry < Lower THEN
    formula_status = 'E'
    formula_message = 'Entry Value Must Be In The Table Range 1'
    ELSE
    formula_status = 's'
    RETURN formula_status, formula_message
    Any help would be very much appreciated.
    Dean

    Hello,
    It is possible to use GET_TABLE_VALUE function in element input validation.
    Thanks,
    Sudhakar

  • How to do input validation in BDC's?

    hai,
       I am Rajesh, I want to know how and where to write input validation code in BDC's. Please help me on this.
    Thanking you

    Hi and welcome
    all key-fields (and fields with a check-table) are checked by SAP-standard in your called transaction in BDC too.
    if you want to validate additional:
    1)load you data from flat file into itab
    2)check fields:
    -against checktable
    -format (date,currency)
    -value
    A.
    pls reward usful answers
    Message was edited by: Andreas Mann

  • Validations in datatable

    Hi
    I have a form generate by a datatable and I want to validate my form with a validator.
    I need to acces to the value of inputs but I don't know how I can acces to it because when I use a binding it don't work.
    I 'll paste my code it will be more clear.
    <h:dataTable value="#{CreerDemandeBean.lesLignesDemandes}" var="uneLigne">
              <f:facet name="header">
                   <f:verbatim>
                        Nombre de jours pour chaque type de Cong�s
                   </f:verbatim>
              </f:facet>
              <h:column>
                   <h:outputText value="#{uneLigne.type.libelle}" />
              </h:column>
              <h:column binding="#{CreerDemandeBean.maListe}">
                   <h:inputText id="nb" value="#{uneLigne.nbjours}" ><f:convertNumber/></h:inputText>
              </h:column>
              <h:column>
                        <h:message for="nb"/>
              </h:column>
              <f:facet name="footer">
                   <h:panelGroup id="panel">
                        <h:commandButton value="Valider" action="#{CreerDemandeBean.validerDemande}"/>
                        <h:commandButton value="Reset" type="reset"/>
                   </h:panelGroup>
              </f:facet>
              </h:dataTable>
              <h:inputHidden id="validate" value="needed" required="true" validator="#{CreerDemandeBean.validate}"/>
              <h:message for="validate" />
    Please help me .....

    In your CreerDemandeBean class, you can have an array list that keeps track of the rows in your table. Example:
    public class CreerDemandeBean {
        private ArrayList lignesDemandes;
        public CreerDemandeBean() {
            lesLignesDemandes = new ArrayList();
            // Add all rows in your table here.
        public ArrayList getLesLignesDemandes() {
            return lesLignesDemandes;
        public void validate(FacesContext context, UIComponent component,
                                           Object value) {
            int i;
            for (i= 0; i < lesLignesDemandes.size(); i++) {
                UneLigne uneLigne = (UneLigne) lesLignesDemandes.get(i);
                // Check content of UneLigne. If not valid, throw ValidatorException.
                // ex.:
                // if (uneLigne.nbjours < 0) {
                //     FacesMessage errMsg = new FacesMessage(msg);
                //     errMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
                //     throw new ValidatorException(errMsg);
       }

  • Validator in dataTable - bug?

    Hi,
    I am using validators in a dataTable, and it works, but in some cases the behaviour is not adequate.
    Some code first :
    <h:dataTable value='#{apps}' var='app'>
         <h:column>
              <f:facet name='header'>
                    <h:outputText value='#{msgs.name}' />
                 </f:facet>
              <h:message for='appname' style='color:red;'/>
           <h:inputText value='#{app.name}' id='appname' required='true' >
               <f:validator .... />
           </h:inputText>
         </h:column>
    As I said - the validation works fine. What is strange is that if a validator is used outside a dataTable, and validation fails, then any new values in the dataTable are lost!! UNLESS (as is here) there is a validator on some field in the dataTable - then if validation fails in the dataTable (regardless if validation outside fails or not) values in the table are preserved, but     then when correct values are entered in the table and validation inside the dataTable succeeds, but fails outside - the validated values on the row in question of the dataTable disappear!!!!! (they are not displayed when the page is reloaded).
    Seams like a bug?
    Is there any way to correct that behaviour, e.g. to force the values in the table that are still not in the model to be kept on the page after outside validation fails and page reloads?
    Thanks for any suggestions!
    Message was edited by:
    ing-uk

    i nee to get the IDs of the component in the Datable
    how can i achieve thatJust get the Object reference itself by getRowData(). Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html how to use datatables.

  • "must choose at least one" validation in dataTable?

    Hello, group,
    How do you validate a set of checkboxes, one per table row, in which the user must select at least one?
    We have a page containing a dataTable, each row of which represents an object, one of whose attributes is "active". Our requirement is that at least one object must be selected as "active" by the user.
    How do we validate this?
    I'm considering the following:
    (1) Put a validator on each checkbox that simply increments a count in a request-scoped bean if the checkbox is checked (and always returns success).
    (2) Put a validator on a hidden field at the bottom of the form that requires the count be greater than zero.
    Is there a better way? (Will this even work at all? :) )
    Thanks.
    John.

    Looks interesting, thank you very much.
    I would actually need the multiple row selector, I think, since the requirement is at least one. I see there's no "validator" attribute, but I assume we could just hang a f:validator off of it (or write our attribute and submit a patch!).
    That jenia component set looks good for some other requirements we have.
    John.

  • Date and Time Input Validation

    Anyone know a good way to validate date and time that a user is entering on the screen.  Our users want to enter AM and PM time vs. Military time. 
    Also, since Input fields don't have an "onBlur" command, what are other companies using in java script.

    What type of DATE/TIME validation are you looking for?
    If you want to validate the format you could simply set the type to date/time and enable the dovalidate attribute to "TRUE".
    for getting onBlur, onChange, etc for your input field you can use bsp:findandreplace.
       <%
      tmp_string =`<input onBlur="javascript:yourjsfunction();"`.
          %>
          <bsp:findAndReplace find    = "<input"
                              replace = "<%= tmp_string %>" >
            <htmlb:inputField id        = "myInputField2"
                              value     = "12345"
                              alignment = "left" />
          </bsp:findAndReplace>
    (courtesy Ulli Hoffmann)
    Hope this helps.
    Regards
    Raja

  • How do link form input and a datatable that are on the same page?

    I am real new to JSF, so I'm having the following issue...
    I created a demo app that will pull records from from a database and display them in a datatable. I hava a backingbean for this process that works great with hardcoded data.
    Now, I want to add a form to this page and use the form input to drive the results in the datatable. I have created my form and used a separate backingbean that is essentially a JavaBean for all the form input.
    My question is how do I integrate the submit button from this new form to feed the call that is used for the datatable?
    Here's is a snippet of the pertinent code from the JSP:
    <TABLE border="0">
                   <TBODY>
                        <TR>
                             <TD>
                             <P>Correlation ID:</P>
                             </TD>
                             <TD><h:inputText styleClass="inputText" id="correlationId"
                                  value="#{LogMessageBean.correlationId}"></h:inputText></TD>
                             <TD width="121"></TD>
                             <TD width="153">
                             <P>Workflow ID:</P>
                             </TD>
                             <TD width="158"><h:inputText styleClass="inputText" id="workItemId"
                                  value="#{LogMessageBean.workItemId}"></h:inputText></TD>
                        </TR>
                   </TBODY>
              </TABLE>
              <BR>
              <div align="center">
              <h:commandButton value="Search" actionListener="#{LogValueListHandler.search}" action="#{LogValueListHandler.result}"/>
              <h:commandButton value="Reset" onclick="reset()"/></div>
              <H5>Application Logging Results</H5>
              <t:dataTable value="#{LogValueListHandler.logList}" var="feed"
                   rowClasses="oddrow, evenrow" headerClass="table">
                   <t:column>
                        <f:facet name="header">
                             <h:outputText value="ClassName" />
                        </f:facet>
                        <h:outputText value="#{feed.className}" />
                   </t:column>
                   <t:column>
                        <f:facet name="header">
                             <h:outputText value="MethodName" />
                        </f:facet>
                        <h:outputText value="#{feed.methodName}" />
                   </t:column>
    ...Thanks!

    Locutus_1,
    I'm working on the same sort of app - A data table where the record selected is displayed in a form below the datatable and may be edited and saved.
    I've included a checkbox in the datatable so that the user can indicate which record is to be displayed and edited. The have everything working, except that I cannot get the checkbox click event passed to the backing bean correctly (critical to the entire operation). When I have this working, I'll post the code.
    This solution does not have a direct link between the datatable model and the data handled by the form. The backing bean code does this. If there was a solution where the two could be linked directly via JSF, I'd be very interested in it.
    Werner

  • BEx WAD - Input validation

    Hi All,
    I'm using BEx WAD to call a query that allows me to see cost center information according to user authorizations thru the Portal. However, if I type an invalid entry then the application returns everything, including nodes that the user is not supposed to be authorized to see. How do I resolve this? Can I do it thru input data validation? Is there another simpler solution?
    Thanks
    Marshall.

    Marshall,
        How are you providing authorization to Query?
    Nagesh Ganisetti.

  • Input Validations

    hi,
    My program require 4 inputs. One parameter(obligatory) and remaining are select-options.I am validating all the fields.
    When I enter wrong value for obligatory field remaining select-options are being disabled(grayed) untill I click on them.
    How to enable them automatically.
    Please help me.

    - Put the parameters/select-options in a [SELECTION-SCREEN BLOCK|http://help.sap.com/abapdocu/en/ABAPSELECTION-SCREEN_BLOCK.htm].
    - Execute you check in a [AT SELECTION-SCREEN|http://help.sap.com/abapdocu/en/ABAPAT_SELECTION-SCREEN.htm] [ON BLOCK|http://help.sap.com/abapdocu/en/ABAPAT_SELECTION-SCREEN_EVENTS.htm#!ABAP_ALTERNATIVE_4@4@] blo.
    When the error will be sent, the whole block keeps editable and the cursor is at the first field of the block.
    Regards,
    Raymond

Maybe you are looking for