Struts - How not to lose parameter after validate() method

Hi
I have following problem. When I submit a form(action= sendMessage.do) from site generated in writeMessage.do?id=1 action and validate method find errors it forwards to writeMessage.do I need to forward to writeMessage.do?id=1
<action path="/sendMessage"
type="SendMessageAction"
name="writeMessageForm"
scope="request"
validate="true"
input="/writeMessage.do">
<forward name="ok" path="/info.jsp"/>
</action>
I need something like input="/writeMessage.do?id=xx" , but xx will be changing in runtime. How to solve that problem?

Swap input="/writeMessage.do" with input="/sendMessage.jsp" (or whatever the name of the input JSP was). If I remember rightly this will fix it for the automatic validation errors, however you'll still get this problem if you need to test business rules/custom validation rules from within your application. To fix this copy the following class and specify a className attribute for your action element in the struts config
i.e. <action ... className="com.whatever.CustomActionMapping" ... />
package com.whatever
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class CustomActionMapping extends ActionMapping
    public ActionForward findForward(String forwardName, HashMap requestParams)
        ActionForward fwd = findForward(forwardName);
        Iterator iter1 = requestParams.keySet().iterator();       
        if (iter1.hasNext())
            StringBuffer basePath = new StringBuffer(fwd.getPath());           
            basePath.append("?");
             while (iter1.hasNext())
                 String paramName = (String) iter1.next();
                 ArrayList paramValues = (ArrayList) requestParams.get(paramName);
                 Iterator iter2 = paramValues.iterator();
                 while (iter2.hasNext())
                     String paramValue = String.valueOf(iter2.next());
                      basePath.append(paramName);
                      basePath.append("=");
                      basePath.append(paramValue);
                      if (iter2.hasNext())
                          basePath.append("&");
                 if (iter1.hasNext())
                     basePath.append("&");
             fwd = new ActionForward(fwd);
             fwd.setPath(basePath.toString());
        return fwd;
}Then in the execute method of your action do something like
// Creates a map to store the request parameters in
HashMap requestParams = new HashMap();
// Helper method to extract a request parameter for 'teamId'
Integer teamId = RequestHelper.getTeamIdParam(request);       
// Adds the teamId parameter to the hash map
setRequestParam(RequestHelper.TEAM_ID, teamId, requestParams);
// Creates a new forward with the required request parameters dynamically appended to the forward path
return ((CustomActionMapping) mapping).findForward(forwardName, requestParams);

Similar Messages

  • I will change my computer, so I'm going to have to sync my iPhone with the new computer. How not to lose my contacts and calendar?

    I will change my computer, so I'm going to have to sync my iPhone with the new computer. How not to lose my contacts and calendar?

    I just need to transfer my contact list on the new computer?
    Ok, thank you for the information!

  • How to define a parameter in a method of type com.sap.tc.webdynpro.progmode

    Hi All,
    I want to define a parameter in a method, type of parameter is com.sap.tc.webdynpro.progmodel.api.IWDNode,
    But when I browse on type and tehn in local dictionary, I do not find this type of datatype, please suggest how to assign this data type to any method's parameter.
    Thanks in Advance.

    Hello Amit,
    Please include  webdynproprogmodel.jar to build path, which can be found at    /sap/eclipse/plugins/com.sap.tc.webdynpro.runtime/lib
    Then you could able to user datatype IWDNode in your code
    Let me know if you need the jar file 
    Regards,
    Madhu

  • Sync iphone how not to lose photo roll?

    I have a iphone and was using itunes on my work PC (winXP). I recently brought the new 13" Macbook, and have been trying to get my iphone to work with the Macbook.
    I manage to transfer all my purchases to the mac, losing only songs copied via CD. I also deactivated the PC so itunes wouldn't think it was registered with another library.
    But the problem is my iphone safari bookmarks, contacts and photo roll, will be deleted from the empty itunes library on sync. Is there anyway to get itunes to copy off the content from iphone, rather then sync no content from the macbook.
    I am going to try the home sharing which is available with the latest itunes, but why is it that itunes does a brand new macbook has more content then my iphone, it really be nice if was two way sync.
    Anyway any suggests would be appreciated.

    Hi rang apple support and from the above managed to sync without any loss of data.
    Apple suggested I could copy the itunes library from XP to Mac but thought this too complicated.
    Also option of home share with version 9 of itunes, but couldn't install it on XP, download dropout.
    What I did :-
    1. I backup the iphone on the exist XP itunes library.
    2. I backup the iphone on the Maxbook itunes store.
    NOTE: Probably overly cautious but didn't wish to lose my contacts, calendar or bookmarks.
    Couldn't find any setting to merge on iphone or itunes but appears it did do this.
    3. I added a dummy contact and calendar entry to both iCal and the address book, as suggested.
    4. Launched iphoto and imported in my photo roll, and set the delete photo option from iphone.
    Need to sync to iphoto before sync itunes photos as itunes sync's to iphoto folder.
    5. Did a full sync.
    I got the standard warning messages, everything being trashed on my iphone and replaced with what was in my library, but didn't loss anything, yeaaaa....
    Thanks for all the help.
    Now trying to resolver bookmark problem with import of bookmarks.

  • Moving Clips - and how not to lose the audio? Help needed!

    Hi,
    I have used Premiere Pro 6.0 quite extensively over the years and have recently moved to Premiere Pro CS5.
    With Premiere Pro 6.0 I could move/drag clips on the time-line and their linked audio would move with them.  If I moved the video clip to another video track, say, above an existing clip, the audio would also move to a free audio track and not automically write over any existing audio.  This would allow me to easily reorder clips on the timeline by simply moving them around and using other video tracks as temporary storage locations... and not lose or write over any other existing audio.
    However in Premiere Pro CS5 if I do the same thing, the video will move to the other video track I move it to, but the audio will stay in the say audio track and will write-over any existing audio when the mouse button is released.  The only way around this I can find in the manual is to: (1) drag the video to the other video track, and (2) press and hold the <SHIFT> key, whilst, (3) draging the linked audio to another audio track to avoid existing audio from being over-written.
    My question:  Is there a configuation I can set in CS5 to allow moving/draging of clips to work like in Premiere Pro 6.0?  I have already messed up multiple times in CS5 by inadvertently over-writing existing audio.
    Your expert advice and recommendations would be greatly appreciated.
    THANKS IN ADVANCE.

    Harm,
    Your reply is not helpful.  Just so you know, I have read through the manual extensively and could not find an answer for my question.  AND that's why I brought my question here.
    Perhaps I missed something in the manual.  Would you mind re-reading my question and helping me if it is so easy?!
    This has been frustrating for me for the last three months and I thought I would come to this forum for some expert advice.  So far I have been told that CS5 is designed to be like this (does not answer my question), and now you tell me to look up the manual (again does not answer my question).
    I'm amazed by responses that miss the question entirely and give helpful suggestions like that!

  • How NOT to re-call after a call break

    Hi,
    I'm using iOS7 on iPhone 4 (in french).
    When a phone call is broken due to bad network, the lock screen displays "Echec d'appel" (in french - I guess in english, it should be something like "Call interrupted"?)
    Sometimes, I DO NOT want to re-call, but I cannot unlock my iPhone without having it re-initiating the last call (even if I slide the bottom of the screen)...
    Is there a way to prevent this "automatic re-call at unlock"???
    Thanks in advance for any clue.

    Hello Peter,
    I was struggling with the same issue.
    NCo provides an delegate for handling change events: RfcDestinationManager.ConfigurationChangeHandler. But I found no documentation about this and could'n get it running.
    Here is my workaround:
    For destination configuration use the way as described in NCo_30_Overview.pdf (page 7 and 8).
    If the compiler warns you, that the event is never used, just add the following line to MyBackendConfig:
    private void ConfigurationChangedEventDummyCall() { ConfigurationChanged(null, null); }
    Change your coding as follows:
    IDestinationConfiguration config = new MyBackendConfig();
    RfcDestinationManager.RegisterDestinationConfiguration(config);
    RfcDestination prd = RfcDestinationManager.GetDestination("PRD_000");
    before you try to get the Repository, execute a Ping and catch the Exception:
    try...
    prd.Ping();
    This prevents you from getting the "Der Wert darf nicht NULL sein" error on the second call.
    If Ping fails, unregister the configuration, change username and/or password, create a new config and register again.
    catch...
    RfcDestinationManager.UnregisterDestinationConfiguration(config);
    // change config here... (prompt for username / password)
    config = new MyBackendConfig();
    RfcDestinationManager.RegisterDestinationConfiguration(config);
    RfcDestination prd = RfcDestinationManager.GetDestination("PRD_000");
    again
    prd.Ping();
    If the second ping is working, logon was ok and you can continue and get the Repository without an error.
    Regards,
    Ingo
    Edited by: Ingo Frank on Sep 19, 2011 4:24 PM

  • How not to lose my contacts and message on a new pc

    I need to sync my iphone with a new pc without losing my contacts, settings, messages etc

    This might help and has been provided by a regular and knowledgeable contributor https://discussions.apple.com/docs/DOC-3141
    If you still have access to your old PC this will be useful http://support.apple.com/kb/HT4527

  • How to use oJavaScript parameter in SubmitForm method?

    Hello,
    I have some difficulties to use the oJavaScript parameter in the submitForm method of document object.
    What I want to do is having a program filling some fields of my form from data the user write in some other fields.
    Then the updated fields will also send a request to get more information from the result of the first request.
    The process works on version 9.x and 8.x of Acrobat, but not for version 7.
    Therefore, I would like to know exactly what happens and add some alert messages, just as it's explained in Acrobat JavaScrit Scripting Reference. Here is what I do :
    this.submitForm({
                    cURL : "http://" + this.getField("serveur").value + "/cgi-bin/acrobat/reqldap#FDF",
                    cSubmitAs :"FDF",
                    bEmpty : false,
                    aFields : tab_champs_requete_infos_LDAP_responsable,
                    oJavaScript : {Before :'app.alert("Start")',
                                         After : 'app.alert("done")'}               
    But even if the script reqldap is succefully executed, I get no alert message...
    I hope someone can explain me why...

    Oh, so THAT's how it works... Thanks for your help! I was expecting to have them displayed before to submit the form and, most important, once the "reqldap" has finished to process the data, as some kind of callback function.
    I would like to be sure the different request doesn't prevent eachother to be processed correctly...There is no apparent reason why I can only make one request to that specific file on the server. All the next call to it will just be ignored when opening the calling form in Acrobat 7 while it will be just fine using Acrobat 9...
    Would you know anything about that?

  • IPhone 3GS Notes loses changes after upgrade to ios4.0.1

    I've restored iPhone software after ios4.0.1 upgrade and Notes still loses content changes. What was bullet-proof application is now worthless until Apple fixes it. I doubt there is any solution other than waiting for new ios release or--how would I do this?--reverting to pre-ios4 OS?

    Delete the email account, reboot the phone, and add it back. If it is a POP3 account you will lose email on the phone. Other types of accounts will resync email.

  • How to recover my database after lose some archivelogs?

    How to recover my database after lose some archivelogs?
    What should I do next?
    When I make a point-in-time recovery, I get the following message:
    Oracle Error:
    ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
    ORA-01152: file 1 was not restored from a sufficiently old backup
    ORA-01110: data file 1: '/u01/app/oracle/oradata/rcatalog/system01.dbf'
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 09/25/2008 16:41:19
    RMAN-06053: unable to perform media recovery because of missing log
    RMAN-06025: no backup of log thread 1 seq 17 lowscn 798237 found to restore
    RMAN-06025: no backup of log thread 1 seq 16 lowscn 796977 found to restore
    RMAN-06025: no backup of log thread 1 seq 15 lowscn 781378 found to restore
    RMAN-06025: no backup of log thread 1 seq 14 lowscn 759019 found to restore
    RMAN-06025: no backup of log thread 1 seq 13 lowscn 709039 found to restore
    RMAN-06025: no backup of log thread 1 seq 12 lowscn 708479 found to restore
    RMAN-06025: no backup of log thread 1 seq 11 lowscn 676234 found to restore
    RMAN-06025: no backup of log thread 1 seq 10 lowscn 646686 found to restore
    RMAN-06025: no backup of log thread 1 seq 9 lowscn 645207 found to restore
    RMAN-06025: no backup of log thread 1 seq 8 lowscn 645199 found to restore
    RMAN-06025: no backup of log thread 1 seq 7 lowscn 595363 found to restore
    RMAN-06025: no backup of log thread 1 seq 6 lowscn 557197 found to restore
    RMAN-06025: no backup of log thread 1 seq 5 lowscn 519102 found to restore
    RMAN-06025: no backup of log thread 1 seq 4 lowscn 519053 found to restore
    RMAN-06025: no backup of log thread 1 seq 3 lowscn 492824 found to restore
    RMAN-06025: no backup of log thread 1 seq 2 lowscn 476888 found to restore

    Mixing thread
    yours recovery asking a lot of archivelog ,you are in the situation now like you are in no archive mode recovery..which requires last cold backup.
    What you can do is restore yours old backup with its old controlfile and then recover till before that miissing log by using recover database using backup controlfile.
    Khurram

  • I have to reinstall Mail as it's not working well. How can I make a back up of my emails so as not to lose them all?

    I have to reinstall Mail as it's not working well. How can I make a back up of my emails so as not to lose them all?

    Thank you for your time Woody. Recently the Mac seems to freeze a lot, seemingly due to a problem with the airport, especially if the computer is inactive for anything more than a few minutes. Then yesterday I suddenly couldn't send or receive messages so I got in touch with my server and they reconfigured the mail account. I can now receive messages but can't send them, always getting a timed out message when I try to send an email. I phoned the server again and they said it must be a problem with Mail as we tried sending a message online from the server's webpage and it worked fine, so they suggested I reinstall Mail. So hence my original question. Sorry for the rambling! I'm not very computer minded.

  • I just bought a new Retina Display macbook pro, and I plugged in my iPod touch (4th gen) into the new computer, but it will not show up, even after I typed in the passcode. How do I get my iTouch to sync with my new computer without restoring my itouch?

    I just bought a new Retina Display macbook pro, and I plugged in my iPod touch (4th gen) into the new computer, but it will not show up, even after I typed in the passcode. How do I get my iTouch to sync with my new computer without restoring my itouch?

    iOS: Device not recognized in iTunes for Mac OS X

  • HT4515 How to make sure that after browsing that the webpage is not running in the background, but totally closed down

    How to make sure that after browsing that the webpage is not running in the background, but totally closed down

    Double tap the Home button, tap & hold the Safari icon until it starts to wiggle, tap the red minus sign to remove it from the Multi-Tasking bar. Tap the Home button when finished.

  • HT4972 my computer will not recognise my iphone after installing the latest version of itunes any ideas how to rectify this

    my computer will not recognise my iphone after installing the latest version of itunes any ideas how to fix this

    iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X - http://support.apple.com/kb/TS1591
    iOS: Device not recognized in iTunes for Windows - http://support.apple.com/kb/TS1538

  • How to use ActionForm validate() method in ADF/Struts project

    Hi
    We are developing a project using ADF/Struts. We are not planning to use entity level validation. Rather we prefer to have it at Struts Form Bean level. So we need to have validate() method in Form Bean.
    That mean we need to have seperate bean for all the actions /jsp. The ADF's DataForm form bean is not gonna work for us. Is that correct.
    Please let me know...am I in the right direction.
    That could be a different discussion why we don't prefer entity level validation

    You can use the Struts validator plug-in (there's a howto on doing that on OTN) and it will handle the basics for you through XML definitions.
    If you want to specifically have a Form bean with a Validate() then the issue is that the current "DataForm" is a generic bean driven of the databinding files, so yes you'd have to write a bean per screen to use instead and loose that benefit of having a universal Bean. (Internally the DataPage and DataActions will respect the ActionForm APIs so you can pluf your own ActionForm subclass in with no problem.
    Plan B might be to leave the DataForm Bean in place and instead override the lifecycle of the datapage, probably in prepareModelUpdates()

Maybe you are looking for