Validations in Web Dynpro Java

Hello,
I'm trying to create a lot of validations in a web dynpro App.
Examples:
  - An inputfield must not pass 6 characters of length. (I can set the inputfield length of 6 characters but I can't force the inputfield to accept only 6 characters).
- Some fields (inputfield, textEdit, dropdownByKey) are mandatory. (I can see the property state = "required" but I don't know how it works)
- Some field are mandatory depending in a previous selection.
I'm finding that adding this validation logic to the form is very heavy and implies a lot of work. I want to ask if someone knows an easy and automatically way to add this validation logic to the app, or I can't escape of programing everything.
Please help.
Regards
SU

Hi SU,
I wrote the following code just to check if this method works or not. Well, this method does work.
Ceate a message in the message pool and use the following code
IWDNode node = null;
wdControllerAPI.checkAndReportRequiredFields(node ,IMessageNew1Comp.VALIDATION__MESSAGE, new Object[]{"test"});
" in my case the attribute bound to the input - whose state is required - is in root container.
"That's why I am passing null as first parameter.
Validation_Message is the message key
"test" is the message which you could pass to the passholder
I hope it helps.
Edited by: Arjun Singh Thakur on Dec 9, 2011 11:32 AM

Similar Messages

  • How to do date validation in Web Dynpro java

    Hi
    We have one requirement that One input field with date type is there.When we take Date type input field then in web dynpro Date navigater is appearing by default.Our requirement is if user enters the date manually in the input filed instead of chossing the date from the Date navigator then how we will do the following date validations manually:
    a. If user is entering the date in any format then it should convert it to dd.mm.yy format.
    b. How to do leap year validation?Suppose user is entering   29.02.20007 then it should display Invalid date.
    c. How to do the follwing date validation:
        Let's say that current running hours(Text Vie
    w) on a given engine is 100, entered on 10-Jun-2008(Running hour date-Text view)).
    -On 15-Jun-2008(New Running Hour Date-input field), I try to enter a value of 300 hours(New running hour-input field).
    -This is impossible, because only 5x24=120 hrs has passed from the previous update.
    -Hence, in this case the maximum value I can enter is 100+120=220.
    Can anybody help me in solving the above 3 date validation?

    Hi Susmita,
    For your 3 rd requirement...
    Initially you will be storing the first date entered by the user right???
    Say that date is D1. and user entered hours is H1.
    now after some days at day D2 user again trying to enter some hours say H2. Now you have to restrict user from entering hours which are
    greater than 24*D2-D1....
    so now you have to get D2-D1....
    For this....
    long l1=youdate1.getTime();   // This will convert your Date D1 into long...
    then,
    Date d=new Date(System.currentTimeMillis());
    long l2=d.getTime();  //which is a long value of current date...
    So Now l2-l1 will give you number of days between past date and today's date...
    So On Save you check for
    if((l2-l1)*24<(H2-H1))
    message("Please enter valied number of hours");
    Hope this will help you....
    Regards,
    Srinivas.

  • Web Dynpro Java code changes

    Hi,
    I need to put some validations in web dynpro java page which is "employee address page". I checked the BADI's but no badi exists which serve my purpsoe.
    Now I want to make the code change in web dynpro java. Pls answer the followng questions.
    1- I have installed NWDS on my local machine. Do i need to install NWDI also?
    2- How to import and export the required page and from where?
    3- How to modify the standard code, I mean in ECC we have enhancement and modification concept.
    Thanks,

    NWDI is a part of NWDS, So you would need both as mentioend
    NWDI - Netweaver Development Infrastructure is an SAP sytem for java development & change management. It's a repository for java code and change management system.
    NWDS is a developer tool to build applications similar to Eclipse. NWDS uses NWDI to check-in & check-out java code and move java changes to SAP runtime systems (like portal etc).
    Read the basics of NWDI and its utility in the below help document
    http://help.sap.com/saphelp_nwce72/helpdata/en/48/bc23b1a70a0611e10000000a42189b/frameset.htm
    Also go through how to import ESS configurations in NWDI
    ESS/MSS Customization – Make it Simple
    NWDI cookbook in SAP note : 872892
    The specified item was not found.
    Edited by: Siddharth Rajora on Nov 9, 2011 9:28 PM

  • Is this possible in Web Dynpro Java?

    Hi,
    Please check if this can be done in Web Dynpro Java...
    public class TestFunction {
         boolean bool =false;
         boolean Test1()
              bool= true;
              return bool;
         void takeBool(boolean b){
              b=this.bool;
              System.out.println("The value of bool "+bool);
         public static void main(String[] args) {
              TestFunction tf = new TestFunction();
              boolean c=tf.Test1();
              tf.takeBool(c);
    Regards
    Kaushik Banerjee
    Edited by: Kaushik Banerjee on Sep 1, 2010 8:00 PM

    Further to what Faraz has said, Web Dynpro can be seen as an implementation of the Framework pattern.
    Essentially you write normal Java code with access to various Java objects exposed/generated by the Web Dynpro Framework inside "hook" functions.
    The Web Dynpro framework then calls your functions at various stages when the page renders and when actions are triggered.
    For a high level understanding of this, not specific to Web Dynpro, research the concept of OO Frameworks pattersn.
    for example [Article explaining frameworks|http://www.cs.wustl.edu/~schmidt/CACM-frameworks.html]
    Here is an excerpt from the above article which highlights the major points
    The primary benefits of OO application frameworks stem from the modularity, reusability, extensibility, and inversion of control they provide to developers, as described below:
    Modularity -- Frameworks enhance modularity by encapsulating volatile implementation details behind stable interfaces. Framework modularity helps improve software quality by localizing the impact of design and implementation changes. This localization reduces the effort required to understand and maintain existing software.
    Reusability -- The stable interfaces provided by frameworks enhance reusability by defining generic components that can be reapplied to create new applications. Framework reusability leverages the domain knowledge and prior effort of experienced developers in order to avoid re-creating and re-validating common solutions to recurring application requirements and software design challenges. Reuse of framework components can yield substantial improvements in programmer productivity, as well as enhance the quality, performance, reliability and interoperability of software.
    Extensibility -- A framework enhances extensibility by providing explicit hook methods that allow applications to extend its stable interfaces. Hook methods systematically decouple the stable interfaces and behaviors of an application domain from the variations required by instantiations of an application in a particular context. Framework extensibility is essential to ensure timely customization of new application services and features.

  • Client side validations in web dynpro

    Hi experts,
    can anybody tell me How we perform client side validations in web dynpro ?
    Thanks,
    Prasad.

    Hi Prasad,
    Validations are generally required during some events or calls to a functions. So there are bascially two ways:
    1) You do the validation is the onActionEvent of the UI element. However this is some time time is not a right approach (depends upon your scenario).
    2) There is another method called wdDoBeforeAction(). Do all you validations for the actions in this method. read the java doc for the same functions, here:
       * Hook method called for additional validation of user input. <p>
       * @param validation Interface for reporting validation errors
    You can catch the particualr action in this emthod and then can write you validation code before the action is called.
    For gettiong the action use this code:
    if(validation.getCurrentAction().equals(IPrivate<Your_View_Name>.WDActionEventHandler.<ACTION_NAME>)){
    // write your validation code here.           
    I hope this will help you. Please revert back in case you have further issues.
    Thanks and Regards,
    Pravesh

  • Logical Destinations in Web Dynpro Java

    Hi!
    Is it possible to access logical HTTP destinations maintained in SAP NetWeaver Administrator via Configuration Management -> Security ->Destinations in Web Dynpro Java source-code.
    I would like to use such a destination to configure an URL target for a IWDFrame UI element.
    Thank you very much in advance!
    Regards,
    Thomas

    I found out that there is a [Destination Service API|http://help.sap.com/saphelp_nwce711/helpdata/en/8b/8e7dac1e661d44bf2a676fd3948cc6/content.htm] for this purpose. Unfortunatly I am still not able to provide the required components security.class and tc/sec/destinations/interface to the web dynpro component. Maintaining them via Project Properties -> Web Dynpro is not allowed any more, and I couldn't find them in the DC perspective to add them as DC dependency.
    Has anybody got an idea where these two libraries have gone?
    Regards,
    Thomas
    PS: The 7.0 procedure, which can be found in various posts, doesn't seem to work any more for CE 711.

  • Date Column not getting sorted in a table in web Dynpro Java

    Hi All,
    I am facing an issue while sorting the date column in a table in my web dynpro java application.
    When the date is displayed in the sql format in tha table, I am able to sort the date column successfully but when we convert the date field from sql format to util format in our table and then sort it does not work.
    Kindly let us know the steps to be followed in this case to sort the date column of a table in Simple Date format as we do not want date in the sql format to be displayed.
    Thanks & Regards,
    Anurag

    Hi,
    You might want to check whether both your browser's language settings are identical. The browser language could also determine the date format.
    As a workaround, you could add an extra attribute to your context, and set the calculated property to 'true'.
    In your table, add a new column and bind to this new attribute, and hide your original date column
    If you sort using the date column that's hidden now, you could use the calculated field to fixed-format your date the way you prefer (by using the SimpleDateFormatter class for instance)
    Cheers,
    Robin

  • How to create a user in UME Database using web dynpro java custom application

    Hi,
    Can you please suggest me how to create a user in UME Database using web dynpro java custom application.
    My Requirement is user can register his/her user id in SAP Portal 7.3 UME database.
    Please suggest me.
    Thanks and Regards,
    Amit

    Hi Amit,
    Generated Documentation (Untitled)
    This is what you're looking for, there's no real cook-book -- though Amey mentioned there might be some material on SDN, perhaps some tutorials.
    You should be looking into com.sap.security.api.IUserFactory, methods newUser(String) which gives you and IUserMaint and commitUser(IUserMaint, IUserAccount) -- IUserAccount can be obtained using com.sap.security.api.IUserAccountFactory, method newUserAccount(String)
    Hope it helps,
    D.

  • How to configure SSO for web dynpro ABAP (not web dynpro Java)

    Hi Experts,
        I am testing SSO in IDES for web dynpro ABAP (Not for web dynpro Java / not for portal). When I am entering url of web dynpro application in web browser like internet explorer, then it should ask for user id and password first time, after login whenever user would access that url, it must not ask for user ID and password (url would be access web browser in mobile). For this I select to configure single sign-on for web dynpro ABAP. I have done below works:
    1). I have created a web dynpro application having url: http://susws076.sap.swk:<port>/sap/bc/webdynpro/sap/zadb_hello_world2
    2). I run TCode SICF and access service node to "Zadb_hello_world2". Double click on it, hit change. pressed "logon data" tab, select "Alternative logon
         procedure"
       Then deleted all logon procedure other than "SSO Authentication" and saved.
    3). Go to "STRUST" and create certificate, choosed "Environment==> Logon Ticket" fill the required parameters and execute. It is OK (no red traffic
         signal).
    4). Execute TCode "RZ10" to change profile parameter, insert new parameter (indicated by red arrow)
    After all this settings I opened a browser enter above URL and hit enter but there is an error
    There is no login page. It directly showed this error page. No cookies is saving.
    Can anyone tell me what all the settings/configuration other than this I have to do. And is there any wrong setting done by me?
    How to set the for single sign-on?
    Thanks in Advance
    Regards
    Piyush

    Hi Piyush,
    Pls refer below links,
    Single Sign On with ABAP WebDynpro
    http://help.sap.com/saphelp_nw70ehp2/helpdata/en/5e/6c85c3edf942f39349a1e337434d29/content.htm
    Regards
    K.N

  • How to set a variable in portal session using web dynpro java.

    Hi,
    I have created a web dynpro application, which is running inside portal. I have created a role called "R1". Inside role R1, i have created 3 workset W1, W2 and W3. and inside each workset i have some pages and iviews.
    My requirement is when user logins to the portal , and when he clicks on role R1 for the first time, a login page should come (so that we can do revalidation), and when he enters his password again in that login page , then only workset W1, W2 and W3 should be visible/accessible to him and after successful revalidation, if he clicks again on role R1, in that particular portal session, than that login page should not come.
    for this, i thought i will set a variable in portal session, whenever user successfully revalidated himself, and if after successful revalidation he clicks again on role R1, i will check in doinit method of webdynpro whether variable is set or not (which i already set on successful revalidation), and if it is set then i will do Donavigation else i will present login page to the user.
    Can anyone tells me how to set a variable in portal session using web dynpro java.
    thanks
    Arush

    Hi,
    Try this:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE, key, value)
    WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE, key)
    Ex:
    WDScopeUtil.put(WDScopeType.CLIENTSESSION_SCOPE,"Key1","Value1");
    String value1=WDScopeUtil.get(WDScopeType.CLIENTSESSION_SCOPE,"Key1").toString();
    /people/william.cui/blog/2007/02/12/sharing-session-context-between-parent-and-external-windows-running-on-same-host
    Regards,
    Charan

  • Web Dynpro Java - Light Portal Desktop

    Hi Guys... I have a web dynpro java application that I want to display on a Light Portal Desktop, but when I display the iview... it gets cut. I mean I can see only part of my application and there is also a right scroll bar... It looks like the height size of the iview is set to "FIXED" but it's not. I Actually  modifed all values for size even on the Light Framework Page used...to FULL_SCREEN. I don't know what's wrong. If I display the same iview using a Default Framework Page it looks fine... I'm using SAP EP 7.00 SP 16.
    Is there any restriction for using Web Dynpro iviews for Light Porta Desktops?
    Thank you.
    David

    David,
    Webdynpro content is considered heavy and I dont think we can use it in LPD.
    Update:
    Note 916545 - Central Note for External-Facing Portal (NW 7.0)
    Check under application.
    Regards,
    Sandeep Tudumu
    Edited by: Sandeep Tudumu on Sep 17, 2008 8:56 PM

  • " APPLICATION NOT FOUND"  while deploying Web dynpro java Application

    Hi, I am getting a message that "application not found " While deploying the web dynpro java application .......... please give me a solution for this .

    Hi Ram,
    This error comes generally when your webdynpro project does not have an application. To create an application in your webdynpro project follow the underlying steps:
    <Project>->WebDynpro->Applications ---> right click and create New Application.
    Follow the steps to create the application.
    Now if you create archive and deploy, it will not give you the error again.
    Best Regards,
    Ravi

  • Accessing ABAP Functions in Web Dynpro Java

    Hi,
    I am trynig to do "Accessing ABAP Functions in Web Dynpro Java" this application, (which is the example application which i got from www.sdn.sap.com) but everything is fine no error also while dyploying.
    But it is not dysplaying the first page after i run the application i am getting plain web page ,without any content.
    Can any body help me.
    Regards,
    H.V.Swathi

    k.. now iam getting some error on page.
    I have embeded the two view in to window.
    But now after running the application i am getting connection error
    com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to message server host failed Connect_PM TYPE=B MSHOST=jktr3 GROUP=SPACE R3NAME=R32 MSSERV=sapmsR32 PCS=1 ERROR Group SPACE not found TIME Fri Sep 26 15:05:59 2008 RELEASE 700 COMPONENT LG VERSION 5 RC -6 MODULE lgxx.c LINE 4288 DETAIL LgIGroupX COUNTER 1
        at com.sap.mw.jco.MiddlewareJRfc.generateJCoException(MiddlewareJRfc.java:457)
        at com.sap.mw.jco.MiddlewareJRfc$Client.connect(MiddlewareJRfc.java:989)
        at com.sap.mw.jco.JCO$Client.connect(JCO.java:3193)
        at com.sap.dictionary.runtime.mdi.DataProvider.<init>(DataProvider.java:90)
        at com.sap.dictionary.runtime.mdi.DataProvider.<init>(DataProvider.java:122)
        ... 61 more
    Rgards,
    H.V.Swathi

  • Reading contents of uploaded excel file in web dynpro java

    Hi All.
    I am aware how to provide facility to upload files in web dynpro java. But my requirement is that on uploading a particular file (for eg. an excel file having 10 columns), I need to read the contents of that file and store it in a table in R/3.Can anyone suggest a way how I can read the contents of the uploaded file?
    Thanks and Regards,
    Saurabh.

    Hi.
    I am having the following requirement : I have a FileUpload UI element where user clicks Browse button, selects a file from the local system and presses a Upload button. Upon pressing Upload, the name of the selected file and the contents of the file should be shown.
    In the View context, I have two value attributes: FileName of type String and FileResource of type binary.
    This is the code that I have in the Upload button action handler :
      public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload(ServerEvent)
        IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(
                 IPrivateReadExcelView.IContextElement.FILE_RESOURCE);
        IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.
                 getModifiableSimpleType();
        IPrivateReadExcelView.IContextElement element = wdContext.createContextElement();
        String fname = binaryType.getFileName();
        wdComponentAPI.getMessageManager().reportSuccess("File selected - "+fname);  //Statement 1
         try {
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    // Statement 2
              InputStream in = new FileInputStream(fname);
              HSSFWorkbook wb = new HSSFWorkbook(in);
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    //Statement 3
              int sheetsNo = wb.getNumberOfSheets();
              for (int i=0;i<sheetsNo;i++) {
                   HSSFSheet sheet = wb.getSheetAt(i);
                   Iterator rowsNo = sheet.rowIterator();
                   while(rowsNo.hasNext()) {
                        HSSFRow rows = (HSSFRow)rowsNo.next();
                        Iterator colsNo = rows.cellIterator();
                        while(colsNo.hasNext()) {
                             HSSFCell cell = (HSSFCell)colsNo.next();
                             wdComponentAPI.getMessageManager().reportSuccess("File uploaded" +
                                  "successfully");
                             if(cell.getCellType()==1) {
                                  wdComponentAPI.getMessageManager().reportSuccess("00000"+
                                       cell.getStringCellValue());
                             else if(cell.getCellType()==0) {
                                  String str=""+cell.getNumericCellValue();
                                  wdComponentAPI.getMessageManager().reportSuccess("11111"+str);
         catch(Exception e) { wdComponentAPI.getMessageManager().raisePendingException();
        //@@end
    On pressing Upload button, name of selected file is being shown(Statement 1). I am also getting Statement 2 in the output. However I am not getting Statement 3 onwards.
    Where am I going wrong? Can anyone shed some light on this?

  • Consuming External Web Services in Web Dynpro Java

    Hi All,
    I an trying to consume external web service in Web dynpro java using Adaptive Web Service Model.
    But getting below mentioned error while executing the web service
    Exception on execution of web service with WSDL URL 'D:\Web Service Project\CurrencyConvertor.asmx.xml' with operation 'ConversionRate' in interface 'CurrencyConvertorSoap'
    Steps i followed are as below:
    1. Created  Adaptive Web Service Model for this i select WSDL source as "Local File System or URL"
    In next step i select No logical destination radio button and click on next
    In next step, browse the WSDL file and successfully import the WSDL file.
    2. After successfully importing the WSDL file i wrote below code in Init method:
    WebModel modelweb = new WebModel();               
    Request_ConversionRate reqConversion = new Request_ConversionRate(modelweb);
    ConversionRate conversion= new ConversionRate(modelweb);
    reqConversion.setConversionRate(conversion);
    wdContext.nodeRequest_ConversionRate().bind(reqConversion);
    3.After that execute the model - code is given below :
        IWDMessageManager manager = wdComponentAPI.getMessageManager();
        try
          wdContext.currentRequest_ConversionRateElement().modelObject().execute();
          wdContext.nodeResponse().invalidate();
          wdContext.nodeConversionRateResponse().invalidate();
        catch(Exception e)
          manager.reportException(e.getMessage(), false);
    Please let me know how to resolve this.
    Thanks
    Sandy

    Hi,
    You need to use destinations for metadata and modeldata.
    Configure those destination in Visula admin.
    you can refer to following link.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b2bc0932-0d01-0010-6d8e-cff1b2f22bc7
    Regards,
    Shruti.

Maybe you are looking for

  • Cannot retrieve definition for form bean null on action /submitCustomerForm

    Can someone plz check my code... while I try to run the code I got Stuck getting the above error report. here is my code.. this is wat i wrote in JSP page <html:form action="/submitCustomerForm"> and in my struts-config I ve.. <form-beans>      <form

  • Acrobat 9.4.2 won't "save"

    When I open PDF documents in Adobe Acrobat Pro 9.4.2, the "Save" option is grayed out. It will let me "Save As ..." It's not a major issue, but it's annoying! I'm running Windows 7 Home Premium 64-bit edition. Any ideas would be welcomed. Thanks. Tim

  • MIR7 Parking & posting error

    Dear Sapguru, We had recently implemented MM-FI module. Invoice is parked/post through transaction code MIR7/MIR6. We have applied the user exit for maker checker validation while parking and posting the document. So the person who will park the docu

  • Strange problem with readObject :(

    I have a classic list-type object, nothing special. I save it in a file with the writeObject method and then i read it with readObject. All works fine, but i recently discovered that if the list has too many elements (i.e. it's too big) and the file

  • Cost roll for multiple plants

    Hi, We have multiple plants where production is carried out. I need to make one plant as standard and standard costs in all other plants should reflect the same cost. One way to do that is to manually copy std cost of each material and paste in MM02