Compairing a form submission using cfselect to a db record

Hello;
I am writting a small contact form. I want to use cfselect so it will be populated with all the states.I have it working fine, my problem is, when the email is sent from the form, it sends the ID of the state, not the actual state name.I am trying to write an if statement to compair the form.state to the record id in the DB and then when it sends the email, it sends the actual state name in the matched db record.
this is my code, it is pretty simple and strait forward.
Contact page
<cfquery name="SESSION.stat" datasource="#APPLICATION.dataSource#" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
SELECT state, ID
FROM States
</cfquery>
<cfform......>
<cfselect enabled="No" name="state" size="1" class="selectstyle" required="yes" message="Please enter your state!" multiple="no" queryPosition="below">
         <option value="" selected>--Select a State--</option>
         <CFOUTPUT query= "SESSION.stat">
         <option value="#ID#">#state#</option>
         </CFOUTPUT></cfselect>
</cfform>
Response page:
<cfquery name="SESSION.stat" datasource="#APPLICATION.dataSource#" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
SELECT state, ID
FROM States
</cfquery>
<cfmail to="[email protected]
        from="#form.email#"
        subject="web siteRequest"
        server="mail.myhost.com"
        port=25
        type="HTML">
<font face="Verdana, Arial, Helvetica, sans-serif" color="##000000" size="2">
<b>Status:</b>           <b>Request!!</b><br>
<!--- this is my error query --->
<cfoutput query="stat">
  C  <b>Customer State:</b>   #state#<br>
  </cfif>
  </cfoutput>
</cfmail>
I think need to fix
  <cfif form.state EQ ('#ID#')>
  <b>Customer State:</b>   #state#<br>
  </cfif>
this is not working properly, and i forget how to compare the orm submission to the DB record. Can anyone help me out?
thank you.
CFmonger

I knew I wasn't thinking right. That did it!
I have a loaded question for you now....
how do you make the cfselect a required field like the other fields so it comes up in the cf-generated java validation code? I have been reading you can only do this by overriding it with it's own java script. Is this true?I do have validation working for it on the server sided response page, just not in the field validation required=Yes" messge="You didn't choose fool!" doesn't work.
Any ideas that do work?
Thank you.

Similar Messages

  • Issue while starting a workflow using a form submission cq5

    Hi,
    I have followed the below mentioned tutorial and completed it.
    http://dev.day.com/docs/en/cq/current/workflows/create-models.html#par_reference
    Once done, I did try to start the workflow using a normal form submission, by giving workflow name in the "Start Workflow" box.
    Once clicked it will send the notification to my inbox, and when I double click, the form 1 will be displayed. Once submitted form two will be displayed.
    But when I submit the form 2, it thorws the below exception.
    But when I start the same workflow using the sidekick, It works perfectly fine. I am guessing that the {payload}.html is not getting set when the WF is initaited by a form submission.
    Could you please help with this. Thank you !
    Exception
    Not Found
    Cannot serve request to /content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/1361448480595_ 27.html in org.apache.sling.servlets.get.DefaultGetServlet
    Request Progress:
          0 (2013-02-21 17:38:19) TIMER_START{Request Processing}
          0 (2013-02-21 17:38:19) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
          0 (2013-02-21 17:38:19) LOG Method=GET, PathInfo=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/13614 48480595_27.html
          0 (2013-02-21 17:38:19) TIMER_START{ResourceResolution}
          1 (2013-02-21 17:38:19) TIMER_END{1,ResourceResolution} URI=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/1361448480 595_27.html resolves to Resource=JcrNodeResource, type=sling:Folder, superType=null, path=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/136144848 0595_27
          1 (2013-02-21 17:38:19) LOG Resource Path Info: SlingRequestPathInfo: path='/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/13614484 80595_27', selectorString='null', extension='html', suffix='null'
          1 (2013-02-21 17:38:19) TIMER_START{ServletResolution}
          1 (2013-02-21 17:38:19) TIMER_START{resolveServlet(JcrNodeResource, type=sling:Folder, superType=null, path=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/136144848 0595_27)}
          1 (2013-02-21 17:38:19) TIMER_END{0,resolveServlet(JcrNodeResource, type=sling:Folder, superType=null, path=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/136144848 0595_27)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet
          1 (2013-02-21 17:38:19) TIMER_END{0,ServletResolution} URI=/content/usergenerated/mywebsite/en/products/product12/cq-gen1361441037192/1361448480 595_27.html handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet
          1 (2013-02-21 17:38:19) LOG Applying Requestfilters
          1 (2013-02-21 17:38:19) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
          1 (2013-02-21 17:38:19) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
          1 (2013-02-21 17:38:19) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource() returns false)
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter
          1 (2013-02-21 17:38:19) LOG Applying Componentfilters
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
          1 (2013-02-21 17:38:19) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
          1 (2013-02-21 17:38:19) TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
          1 (2013-02-21 17:38:19) LOG No renderer for extension html
          1 (2013-02-21 17:38:19) LOG Applying Error filters
          1 (2013-02-21 17:38:19) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
          1 (2013-02-21 17:38:19) TIMER_START{handleError:status=404}
          1 (2013-02-21 17:38:19) TIMER_END{0,handleError:status=404} Using handler /libs/sling/servlet/errorhandler/404.jsp
          2 (2013-02-21 17:38:19) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=org.apache.sling.jcr.resource.JcrPropertyMap@88fc5d1), Config(type=mobiledebug, config=org.apache.sling.jcr.resource.JcrPropertyMap@170420bb), Config(type=contentsync, config=org.apache.sling.jcr.resource.JcrPropertyMap@1000e0cb), serializer=Config(type=htmlwriter, config={}))}
          2 (2013-02-21 17:38:19) TIMER_END{2,Request Processing} Dumping SlingRequestProgressTracker Entries
    ApacheSling/2.2 (Day-Servlet-Engine/4.1.24, Java HotSpot(TM) 64-Bit Server VM 1.7.0_07, Windows 7 6.1 amd64)

    Hi chamila,
        I never tried the example. Exception is not clear. Could you please post more stack trace from log files.
    Thanks,
    Sham

  • Referencing "image" form elements using Safari

    I'm trying to write an Applescript which uses Safari's do JavaScript feature to reference the elements of forms in web pages. I've run into a puzzle in cases where the page designer chose to use an element of type "image" for form submission. It looks to me as though input tags with a type attribute of "image" are not being represented in the JavaScript elements array for the form.
    Here's a mini-script to display a list of the element types within a form on a web page:
    set formName to "loginForm"
    set types to {}
    tell application "Safari" to tell front document
    set elementCount to do JavaScript "document." & formName & ".length"
    repeat with elementNumber from 0 to elementCount - 1
    copy (do JavaScript "document." & formName & ".elements[" & (elementNumber as text) & "].type") to end of types
    end repeat
    end tell
    set text item delimiters to {space & "/" & space}
    display dialog types as text
    Before running, I find a web page with a login box, and look at the page code to find the name of the form in question, in this case "loginForm" and put that name in the first line of the script. Then I bring the page in question to the front and start the script.
    For one page, I got the result "hidden / hidden / text / text / hidden / checkbox / password / checkbox / submit" and when I checked this against the page code, I found it was correct: there were nine <input> tags in the form, and their type attributes were in that order. But for another page, the home page of a major credit card, I got the result "hidden / text / password / select-one / checkbox" when I was expecting "hidden / text / password / select-one / image / checkbox." I've tried this with other pages and the behavior seems consistent: all types of <input> tags are represented in the elements arrays of their forms, except <input type="image"> which are always left out.
    So, is this a bug or a feature? Or am I just unclear on the concept of the elements array? And if so, is there another way to find the submit element of a form when it is an "image"?
    Incidentally, I'm not trying to be cagey by leaving out links to the pages I've tested. I'm just fairly new to discussion groups and was worried that linking to third-party pages for what amounts to a science experiment might not be the best net etiquette. If someone knows better, I will accept instruction. I hope my question is clear anyway, and there is no shortage of pages for experimental subjects.

    True, it is not a matter of AppleScript per se. I did look for an Apple forum on JavaScript but didn't see one. OS X Technologies > AppleScript looked like my best bet: I've seen quite a few postings here where the answer to a question involved JavaScript, Unix shell scripts, PHP, etc., so I don't think I'm far off the mark. And I didn't think of a non-Apple JavaScript forum because I don't think my question is about JavaScript per se either: I suspect it is about Apple's implementation of JavaScript.
    You're quite right about what I'm trying to do. I have a script that transfers secure data from my keychains into web forms, and there's really no need to trigger the form submittal programmatically when I have a perfectly good mouse and index finger, but it's become an enjoyable intellectual challenge to make it happen automatically. Incidentally, what you suggest may actually be a little dangerous these days: at any rate, that simple document.formName.submit(); method is more likely to fail than succeed.
    Short version: physically clicking on a submit button on a web page in the conventional way is likely to invoke a lot of validity checking code in the page before the form is actually submitted. If, for example, there is a credit card number in the form, there will probably be code to do a Luhn checksum to make sure you've entered a real credit card number. If the validation fails, the submittal can be aborted. Using the .submit() method, by itself, does not trigger this validation code. (I fervently believe there is an excellent reason for this, but I've no idea what it might be.) Because of this, the form may be submitted with hidden element values that quite probably reflect the lack of validation. The server detects the anomaly, and instead of logging you in, it sends you to an error page. That's probably the best that can happen. I can think of worse.
    My script has provisions to "play by the rules" by invoking any such validation code, and respecting its decision whether or not to proceed with submittal. I have the script working very well, but there's always the possibility of some web page designer doing something which I have not correctly anticipated. (In fact, since one possible place to put validation code invocations is in the "onclick" handler of the submit button, and since I'm having trouble finding some of these, I know I'm not covering all bases.)
    A much more foolproof strategy would be to just simulate the physical clicking of a button. This is straightforward:
    set submitButton to "document.formName.submitButtonName"
    tell application "Safari" to tell front document
    do JavaScript submitButton & ".focus();" & linefeed & submitButton & ".click();"
    end tell
    And to date I've never seen this method fail. But to do it, I have to have the name, or the array index, of the submit element of the form. I thought I knew how to find this, in the form's elements array, but I've run into a strange phenomenon. There are two kinds of submit buttons in forms: type="submit" and type="image". The type="submit" buttons do appear in the elements array, but the type="image" buttons apparently do not. And since web designers love to spiff up their pages, type="image" seems to be far more common these days.
    I suspect this is just something that was accidentally left out of Apple's implementation of the JavaScript document model. I just thought I would ask if anyone else was aware of this, and could confirm or disconfirm. If no one does in the next day or so, I will bring the matter to the attention of the good people at Apple Bug Reporter.
    All the best.

  • Create a JSON file from a form submission

    Hi there, I am trying to create my first BC app but struggling to find a solution to create some data inside BC, I need to create a JSON file from a form submission that will be used as feed for my app.
    How I see it working:
    - Form submits details { Name, Email, Phone Number and a Date.} to a JSON file.
    - My app.js will read the JSON file and populate the content on a graph.
    Any other ideas will be much appreciated.
    I don't know if BC is has another way to host data from an app! but if you know pleas share.

    Hi Liam I must be explaining it wrong then, I am creating a BC App not an WebApp, At the moment I have my BC App generating the WebApp but once its done the JSON is generated somewhere in BC where i cannot fetch I tried using some directories to fetch it.
    I created the app this way:
    function tryWebAppCreate(data, xhr) {
        $.getJSON("booking-data/webapp.json")
            .done(function(webAppJsonDescriptor) {
                createWebApp(WEBAPP_NAME, webAppJsonDescriptor.webAppCustomFields, webAppJsonDescriptor.webAppSampleData, loadTeamMembers);   
            .fail(function() {
                systemNotifications.showError("Could not load webapp definition file");
    But now to fetch it i tried: ( replacing the braces with appropriate IDs)
    /api/v2/admin/sites/[site id]/webapps/[app id]/webappp.json
    My 3rd party App will connect to my BC App and from my app i have another call to send the JSON info.
    I just cant call it! maybe if you know how please let me know.

  • Struts portlet page going out of context during form submission

    I?m working on the Weblogic 8.1 version and have a struts portlet inside a portal alongwith the other portlets. When a html link is used, the jsps remain inside the portal context but during a form submission, the request is processed and the jsp is displayed out of the portal as a separate application.
    I?m using the request.getContextPath() in the jsp but still it is not workin.
    Is there anything I should be modifying or that has to make it work?
    What are the changes (if any) has to be made for the form submission in a jsp with regard to a Struts Portlet such that the form submission stays inside the parent portal context.

    The Images can be accessed from modified location
    PersonalDataPortlet-In-Portal.jpg : http://portal.plumtree.com/portal/server.pt/gateway/PTARGS_0_213205_4520_0_-213205_43/http%3B/PRODGADGET12.plumtree.com/collab/docman/download?fid=107617&ver=0&rndm=1085565825500&name=PersonalDataPortlet-In-Portal.jpg
    PersonalDataPortlet-Search.jpg : http://portal.plumtree.com/portal/server.pt/gateway/PTARGS_0_213205_4520_0_-213205_43/http%3B/PRODGADGET12.plumtree.com/collab/docman/download?fid=107618&ver=0&rndm=1085743844250&name=PersonalDataPortlet-Search.jpg
    PersonalDataPortlet-Result.jpg : http://portal.plumtree.com/portal/server.pt/gateway/PTARGS_0_213205_4520_0_-213205_43/http%3B/PRODGADGET12.plumtree.com/collab/docman/download?fid=107619&ver=0&rndm=1085743844250&name=PersonalDataPortlet-Result.jpg

  • SSL certificate - securing web form submission - privacy, usability and Adobe's UX design ethos

    Hi,
    (newbie alert)
    I'm just learning BC and it doesn't seem too bad. One problem I have is the shared certificate and I wonder if there are plans to address this shortcoming in the short term?
    Privacy is a growing concern in Australia (in addition to specific new legal requirements). The web forms that we will use are likely to contain personal information. These should be secured by a certificate.
    If you accept that most end users are not tech-savvy then you might agree with the premise that "Users should not see different domain names in the address bar when submitting personal information".
    Switching domains, multiple times for web forms submission or ecommerce, is in my view, a pretty simplistic and business-centric (as opposewd to user-centric) design approach to the task.
    How does Adobe explain their committment to the end-user and their system design decisions regarding the shared certificate situation? I'd be interested to know if Adobe believes this is a "good-enough" solution based on a range of factors, especially expediency for Adobe. Or are there concrete plans to "fix" this (in my view) sub-optimal situation in the near-term?
    Happy to discuss further.
    Cheers
    BCStarter

    Hey there,
    It is an integral part of how the system works in terms of the system itself and the business model, So it wont be any way to change it any time soon without a big change from BC on how BC works.
    Web forms in BC can be secured with a certificate. Many systems change domain for secure subdomains etc, most people are not tech savy and they actually do not even notice things like change of domain, most actually do not check the SSL certificate. You can even just put graphics of lock symbols and say your form is secure, even when it is not and people fill it in. (Studies have shown this)
    With many eCommerce sites, booking sites etc under my belt, with good UI Design and site flow and good information about being secure etc to the end user - No issues with clients and clients happy with the sales they get through. The domain thing has never been an issue.
    I seen people complain about it on the forums before but looking at the sites, its the user experience flow of the site itself being the primary problem.
    Yep, nice if it was all under the same domain, but this will not likely change in BC especially any time soon, but a site built well - this really does not matter that much, Google for example even offers anaytlitcs settings to work cross domain so they fully well know things like this work on modern websites.

  • Errored during request submission using request see APIs

    Hi guys, this error is giving me when i call a concurrent program and do a request sumission and the request status is red(error) with the next error:
    "Errored during request submission using request see APIs "
    Im using forms 6i and EBS

    Hi,
    I am getting the exact same error.
    It appears when we run request sets!
    We have made a trigger that sends an email to our sysadmins every time a concurrent request fails. This trigger fires on insert or update of applsys.fnd_concurrent_requests when new.status_code = 'E' /*Error*/ and new.phase_code ; = 'C' /*Complete*/.
    In other words we should only get a message when the request has the status Error and is Complete.
    However for request sets we get an email saying that it has failed with the following message "Errored during request submission using request see APIs". BUT, when we query the request in the Application, it has the status Normal! This applies to several different request sets.
    So, my question is: Does anyone know if, or why, the standard request submission of request sets updates the status to Error for a short time, and then updates it to Normal afterwards?
    Thanks
    Roy

  • How to prevent dupilcate form submission in JSF 1.x

    Hi All
    How to prevent dupilcate form submission in JSF 1.x application. As of now ,when the user clicked the submit button two times , application inserts 2 records in database.
    Please suggest how to prevent dupliacte form submission without using Javascript. Kindlly share examples if any.
    Regards,
    DEV

    Your problem is not really double submission but the fact that your application allows double insertion. The fix is functionally easy but technically very cumbersome: before inserting, check if the data already exists. If you build in such a guard you also protect against other methods of causing a resubmission, such as the browser back button.
    PS: what's the deal with the no javascript limitation? You do realize that when you use JSF you're tanking your application full of javascript, right?

  • I want to use cfselect....

    Hi All,
    I want to use cfselect to act as a parameter for querying specific data. My questions are:
    1. What the maximum keywords can I select?
    2. How can I get that to my action page to query the multiple selections?
    Ex.
    <cfquery>
    Select *
    FROM tblname
    WHERE dateprod = '#FORM.Defect_Title#' or dateProd LIKE '#FORM.Defect_Title#'
    </cfquery>
    Does this make sense? I get nothing when I attempt this when selecting multiples or when I select one I get double that one.
    Thanks in Advance,
    DJ Khalif   

    1. I don't think that there is a constraint on the number of items that can be selected in a CFSELECT if multiple="yes".  Someone please correct me if I am mistaken.
    2. I believe that the selected items will be passed in a comma delimited string.  Assuming that Defect_Title is your CFSELECT tag name your query would look like the sample below.  The syntax may vary based on your database server version and the data type of the dateprod field.
    If this doesn't help please post your code and some sample data along with a description of what you are trying to accomplish.
    <cfquery>
    Select *
    FROM tblname
    WHERE dateprod IN ( <cfqueryparam value"#FORM.Defect_Title#" cfsqltype="cf_sql_varchar" list="yes" /> )
    </cfquery>
    CFQUERYPARAM
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_18.html#1102474

  • Mandatory check box before form submission

    I want users to accept my 'Terms & Conditions' statement on an application form before they are allowed to submit it by the e-mail button.
    I want to place a required check box which produces an error message and prevents form submission until it is checked.
    I have read hordes of the postings but none of the solutions seem to do quite what I want.
    Any advice would be gratefully received

    Hi,
    I used the script you provided in the above post, and it worked perfectly, but my situation is a little different: I have two checkboxes, but I only want the message to appear if one of them isn't selected. If the other checkbox is selected, I need the fake submit button to go ahead and generate the email to send the form. I'm new to LiveCycle Designer, and I'm unsure of how to correctly use the "if" and "else" javascript. I need the message to appear when clicking the WebExYes checkbox, but I don't want it to appear when the user clicks the IntercallCheckBox.
    Here's what my script looks like so far:
    if 
    (form1.subForm1.WebEx.WebExYes.rawValue != "1"){ xfa.host.messageBox("You must read the FHEG WebEx Usage Standards and select the Yes checkbox before submitting.");
    else 
    { SubmitButton.execEvent("click");
    if 
    (form1.subForm1.AccountRequest.IntercallCheckBox.rawValue != "1")
    else 
    {SubmitButton.execEvent ("click");
    Can someone tell me what I'm doing wrong or if I can even make this happen?
    Thank you,
    Hannah

  • How do I create an app from my Adobe pdf forms to use on any mobile device as well as windows and ios?

    How do I create an app from my Adobe pdf forms to use on any mobile device as well as windows and ios? I have all the apps in Creative Cloud by the way.

    If you already purchased it with the same Apple ID, then you will not be re-charged.

  • CRM 2011: Can you control which form is used based not security roles, but on a field value?

    I see that you can control which form is used based on security roles, but can you control it based on other field values?  I'd like a new record to use a different form until a given status is updated.  I have a status of draft and active. So
    it would be nice if I could use form1 for those in draft, form2 for those that are active.  But I only see where you can control that via the security roles.
    I can code all of this via JavaScript, but having the ability to use two separate forms would be nice.  Is that even possible.
    Best regards,
    Jon Gregory Rothlander

    Hello,
    Recheck following article - http://gonzaloruizcrm.blogspot.com/2014/11/avoiding-form-reload-when-switching-crm.html
    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

  • Can you create a form not using a php script?

    I need to create a contact us form on my website using DW and have researched how and understand the easiest way is using a php script.  Unfortuntately, my webhost server does not support this and will charge me an arm and a leg in order to to do it.  Is there another way to have a functioning contact form not using a php script?

    Yes and no.
    You could use a mailto link for your form action instead of a PHP script.
    There are several problems with this method though. First, when you do that, you are at the mercy of the viewer's computer set-up. Mailto links use whatever email client is installed on the machine in order to send the message. Public computers (libraries, colleges, etc) almost never have an email client installed, so when a viewer on one of those machines clicks the link, nothing happens. Secondly, your email address is open for spam harvesters, so you may end up with enlargement and nigerian scam emails flooding your inbox.
    Since your provider doesn't give you a way to do it the right way on your server, you may want to look into email form services online and see if they are less expensive than your current alternative.

  • How can i convert my encrypting file to a applet form to use it in IE?

    Hi, i m a little new in JAVA.
    I searched about encryting methods. And i decide to built a encrypter that reads a string from a textbox and writes the encrypted form to another textbox.. this code is working in eclipse. but i cannot convert this to applet form to use it in internet explorer .. i dont know why this not work. It says : "Applet password notinited" -> How can i solve this problem ???
    Please HELP ME ! Thanks alot..
    package yeni;
    import java.applet.*;
    import java.awt.*;
    import java.lang.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class password extends java.applet.Applet
         SecretKeySpec keyS;
         SecretKey key;
         SecretKey key_s;
         String encrypted;
         String decrypted;
         KeyGenerator keyGen;
         Mac mac;
         byte[] utf8;
         byte[] digest;
         private Button b_open;
         private Button b_next;
         private TextField t_userID;
         private TextField t_password;
         private TextField re_userID;
         private TextField re_password;
         private Label l_title;
         private String root;
         private int col;
         private String title;
         private String buttontxt;
         private int bgcolor;
         private int fsize;
         private String fface;
         private String errorURL;
         /* Init */
         public void init()
              String att = getParameter("root");
              root = (att == null) ? this.getDocumentBase().toString() : att;
              att = getParameter("textfield");
              col = (att == null) ? 20 : (Integer.valueOf(att).intValue());
              att = getParameter("font_size");
              fsize = (att == null) ? 11 : (Integer.valueOf(att).intValue());
              att = getParameter("font_face");
              fface = (att == null) ? "Arial" : att;
              att = getParameter("color");
              bgcolor = (att == null) ? Color.white.getRGB() : (Integer.parseInt(att, 16));
              att = getParameter("title");
              title = (att == null) ? "" : att;
              att = getParameter("button");
              buttontxt = (att == null) ? "OPEN" : att;
              att = getParameter("wrong");
              errorURL = (att == null) ? "" : att;
              setFont(new Font(fface, Font.PLAIN, fsize));
              setBackground(new Color(bgcolor));
              b_open = new Button(buttontxt);
              b_next = new Button("NEXT");
              t_userID = new TextField(col);
              t_password = new TextField(col);
              re_userID = new TextField(col);
              re_password = new TextField(col);
              l_title = new Label(title);
              t_userID.setBackground(Color.white);
              t_password.setBackground(Color.white);
              t_password.setEchoCharacter('*');
              re_userID.setBackground(Color.YELLOW);
              re_password.setBackground(Color.YELLOW);
    //          re_password.setEchoCharacter('-');
              setLayout(new FlowLayout(FlowLayout.CENTER,3,3));
              if(title.length()>0)
                   add(l_title);
              add(t_userID);
              add(t_password);
              add(b_next);          
              add(b_open);
              add(re_userID);
              add(re_password);
              t_userID.setText("User ID");
              t_password.setText("Password");
              //re_password.hide();
              //re_password.hide();
              show();
         /* Transfer - �ifreleleme */
         void transfer()
              if(t_userID.getText().length()>0)
                   re_userID.setText(t_userID.getText());
              else t_userID.setText("Enter Your USER ID!");
              if(t_password.getText().length()>0)
                   //Calling HMAC Function
                   re_password.setText(HMAC(t_password.getText()));
         /* HMAC Fonksiyonu - �ifreleme */
         public String HMAC(String values){
             String output = "";
             try {
                 //Generate a key for the HMAC-MD5 keyed-hashing algorithm;
                 key =  new SecretKeySpec( "istenen anahtar".getBytes("ASCII"), "HmacMD5");
                 // Create a MAC object using HMAC-MD5 and initialize with key
                 mac = Mac.getInstance("HmacMD5");
                 mac.init(key);
                 // Encode the string into bytes using utf-8 and digest it
                 utf8 = values.getBytes("UTF8");
                 digest = mac.doFinal(utf8);
                 //If desired, convert the digest into a string
                 String digestB64 = new sun.misc.BASE64Encoder().encode(digest);
                 output += digestB64;
             catch(Exception e){}
             return output;
         /* surfto_error Fonksiyonu - Hata durumu */
         void surfto_error()
              if(errorURL.length()>0)
                   try
                        getAppletContext().showDocument(new URL(errorURL),"_self");
                   catch (MalformedURLException e) {}
              else
                   re_password.setText("");
                   showStatus("Invalid password!");
         /* surfto Fonksiyonu - Bilgi Aktar�m� */
         void surfto()
              if(t_password.getText().length()>0)
                   try
                        URL surftoURL = new URL(root+t_password.getText()+".html");
                        InputStream in = surftoURL.openStream();
                        in.close();
                        getAppletContext().showDocument(surftoURL,"_self");
                   catch (MalformedURLException e) { surfto_error(); }
                   catch (SecurityException e) { surfto_error(); }
                   catch (IOException e) { surfto_error(); }
         /* Durum ��leme */
         public boolean handleEvent(Event evt)
              if(evt.id == Event.KEY_PRESS && evt.target == t_password && evt.key==10)
                   surfto();
                   return(true);
              return super.handleEvent(evt);
         /* Eylem ��leme  */
         public boolean action(Event evt, Object arg)
              if (evt.target == b_open)
                   surfto();
                   return true;
              if (evt.target == b_next)
                   transfer();
                   return true;
              return(super.action(evt,arg));
    }

    In method HMAC, you have towards the bottom
    catch(Exception e) {}please change this to
    catch(Exception e)
                e.printStackTrace();
            }Note that using the sun.* classes, including the sun.misc.BASE64Encoder class, requires elevated privileges (see http://forum.java.sun.com/thread.jspa?threadID=483223&messageID=2255882).
    It is not difficult to write your own encoder/decoder class, or borrow one from someone else. Just google on "java base64 encoder".

  • Use of us_screen in the form routine :  FORM entry USING retcode us_screen

    Hello All,
    I have one print program entry routine as below.
    FORM entry USING retcode us_screen.
    Some code to print the form data...
    EndForm.
    When i Check the value of us_screen in the debuging, its value is coming as blank.
    When i checked the other form routine the value of us_screen is coming as 'X.
    I am my getting why in my case value of us_screen is coming as blank.
    What is significant of this field.
    Thanks & Regards
    Sachin Yadav

    Cusomization might be missing for that output type in transaction NACE.
    us_screen is blank because below query fails due to missing entry in table TNAPR.
    SELECT SINGLE * FROM TNAPR WHERE KSCHL = P_KSCHL
                               AND   NACHA = P_NACHA
                               AND   KAPPL = P_KAPPL.
    First assign the output type with a Transmission medium, Program, Form Routine, Form in transaction NACE
    Take the help of your functional consultant.

Maybe you are looking for