lundi 31 juillet 2017

Struts 1.x to Struts 2.x Migration issues in passing Java Method Parameters from JSP to Action Class

I am working on Struts 1.x to Struts 2.x migration and I am facing issues where some method is not able to pass parameter to setter method written in Action Form class from JSP page.

For your reference please find the POJO class :

import java.io.Serializable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * The Class ShareFeedbackForm.
 */

    public class ShareFeedbackForm implements Serializable {


        /**
         * 
         */
        private static final long serialVersionUID = 5070305198069278831L;

        private static final Log LOG = LogFactory.getLog(ShareFeedbackForm.class);

        /** The section. */
        private String section;

        /** The department. */
        private String department;

        /** The kst. */
        private String kst;

        /** The physical path. */
        private String physicalPath;

        /** The dfs path. */
        private String dfsPath;

        /** The share owner. */
        private String shareOwner;

        /** The share mgr. */
        private String shareMgr;

        /** The share id. */
        private String shareId;

        /** The revision id. */
        private String revisionId;

        private String revisionName;

        private String revisionDate;

        private String writeAccess; 

        private String headerCheck;

        private String reviewer ;

        private String reviewedOn;

        private String orderId ;

        private String uamTeamAccess;

        private String completed;

        private String lockedRev;

        private String sharePath;

        private String isSent;

        private String errorInfo;

        /**
         * @return the isSent
         */
        public String getIsSent() {
            return isSent;
        }


        /**
         * @param isSent the isSent to set
         */
        public void setIsSent(String isSent) {
            this.isSent = isSent;
        }


        public String getSharePath() {
            return sharePath;
        }


        public void setSharePath(String sharePath) {
            this.sharePath = sharePath;
        }


        /**
         * @return the lockedRev
         */
        public String getLockedRev() {
            return lockedRev;
        }


        /**
         * @param lockedRev the lockedRev to set
         */
        public void setLockedRev(String lockedRev) {
            this.lockedRev = lockedRev;
        }


        /**
         * @return the completed
         */
        public String getCompleted() {
            return completed;
        }


        /**
         * @param completed the completed to set
         */
        public void setCompleted(String completed) {
            this.completed = completed;
        }


        /**
         * @return the headerCheck
         */
        public String getHeaderCheck() {
            return headerCheck;
        }


        /**
         * @param headerCheck the headerCheck to set
         */
        public void setHeaderCheck( String headerCheck ) {
            this.headerCheck = headerCheck;
        }


        /** The Attachment List to String. */
        private String strAttachment;

        /** The Attachment Report. */
        private List<String> attachmentReport = new ArrayList<String>();

        /** The LstSecWin Report. */
        private List<String> lstSecWinReport;

        /** The String LstSecWin Report */
        private String strLstSecWinReport;

        /** The additional comments. */
        private String additionalComments;

        /** The sfhf lst. */
        private List<ShareFeedbackHelperForm> sfhfLst;

        private Set<String> checkedAllIds = new HashSet<String>();

        private Map<Long,String> checkedRemarks = new HashMap<Long, String>();

        public Set<String> getCheckedAllIds() {
            return checkedAllIds;
        }


        public void setCheckedAllIds( Set<String> checkedAllIds ) {
            this.checkedAllIds = checkedAllIds;
        }


        public Map<Long, String> getCheckedRemarks() {
            return checkedRemarks;
        }


        public void setCheckedRemarks(Map<Long, String> checkedRemarks) {
            this.checkedRemarks = checkedRemarks;
        }

        public String getCheckAll( String id ) {
            String h = "";
            try {
                h = String.valueOf( this.checkedAllIds.contains( id ) );
            } catch ( Exception e ) {
               LOG.error(" Exception in getting the checked check boxes :",e);
            }
            return h;
        }


        public void setCheckAll( String id, String value ) {
            this.checkedAllIds.add( id );
        }

        public String getCheckAllRemarks( String id ) {
            String h = "";
            try {
                h = String.valueOf( this.checkedRemarks.get(Long.valueOf(id)) );
            } catch ( Exception e ) {
               LOG.error(" Exception in getting the checked remarks :"+e);
            }
            return h;
        }


        public void setCheckAllRemarks( String id, String value ) {
            this.checkedRemarks.put(Long.valueOf(id), value);
        }



        public String getRevisionDate() {
            return revisionDate;
        }


        public void setRevisionDate(String revisionDate) {
            this.revisionDate = revisionDate;
        }


        /**
         * Gets the revision id.
         *
         * @return the revision id
         */
        public String getRevisionId() {
            return revisionId;
        }

        /**
         * Sets the revision id.
         *
         * @param revisionId the new revision id
         */
        public void setRevisionId(String revisionId) {
            this.revisionId = revisionId;
        }



        public String getWriteAccess() {
            return writeAccess;
        }


        public void setWriteAccess(String writeAccess) {
            this.writeAccess = writeAccess;
        }


        /**
         * Gets the share id.
         *
         * @return the share id
         */
        public String getShareId() {
            return shareId;
        }

        /**
         * Sets the share id.
         *
         * @param shareId the new share id
         */
        public void setShareId(String shareId) {
            this.shareId = shareId;
        }

        /**
         * Gets the section.
         *
         * @return the section
         */
        public String getSection() {
            return section;
        }

        /**
         * Sets the section.
         *
         * @param section the section to set
         */
        public void setSection(String section) {
            this.section = section;
        }

        /**
         * Gets the department.
         *
         * @return the department
         */
        public String getDepartment() {
            return department;
        }

        /**
         * Sets the department.
         *
         * @param department the department to set
         */
        public void setDepartment(String department) {
            this.department = department;
        }

        /**
         * Gets the kst.
         *
         * @return the kst
         */
        public String getKst() {
            return kst;
        }

        /**
         * Sets the kst.
         *
         * @param kst the kst to set
         */
        public void setKst(String kst) {
            this.kst = kst;
        }

        /**
         * Gets the physical path.
         *
         * @return the physicalPath
         */
        public String getPhysicalPath() {
            return physicalPath;
        }

        /**
         * Sets the physical path.
         *
         * @param physicalPath the physicalPath to set
         */
        public void setPhysicalPath(String physicalPath) {
            this.physicalPath = physicalPath;
        }

        /**
         * Gets the dfs path.
         *
         * @return the dfsPath
         */
        public String getDfsPath() {
            return dfsPath;
        }

        /**
         * Sets the dfs path.
         *
         * @param dfsPath the dfsPath to set
         */
        public void setDfsPath(String dfsPath) {
            this.dfsPath = dfsPath;
        }

        /**
         * Gets the share owner.
         *
         * @return the shareOwner
         */
        public String getShareOwner() {
            return shareOwner;
        }

        /**
         * Sets the share owner.
         *
         * @param shareOwner the shareOwner to set
         */
        public void setShareOwner(String shareOwner) {
            this.shareOwner = shareOwner;
        }

        /**
         * Gets the share mgr.
         *
         * @return the shareMgr
         */
        public String getShareMgr() {
            return shareMgr;
        }

        /**
         * Sets the share mgr.
         *
         * @param shareMgr the shareMgr to set
         */
        public void setShareMgr(String shareMgr) {
            this.shareMgr = shareMgr;
        }

        /**
         * Gets the additional comments.
         *
         * @return the additionalComments
         */
        public String getAdditionalComments() {
            return additionalComments;
        }

        /**
         * Sets the additional comments.
         *
         * @param additionalComments the additionalComments to set
         */
        public void setAdditionalComments(String additionalComments) {
            this.additionalComments = additionalComments;
        }

        /**
         * Gets the sfhf lst.
         *
         * @return the sfhfLst
         */
        public List<ShareFeedbackHelperForm> getSfhfLst() {
            return sfhfLst;
        }

        /**
         * Sets the sfhf lst.
         *
         * @param sfhfLst the sfhfLst to set
         */
        public void setSfhfLst(List<ShareFeedbackHelperForm> sfhfLst) {
            this.sfhfLst = sfhfLst;
        }

        /**
         * Gets the str attachment.
         *
         * @return the strAttachment
         */
        public String getStrAttachment() {
            return strAttachment;
        }

        /**
         * Sets the str attachment.
         *
         * @param strAttachment the strAttachment to set
         */
        public void setStrAttachment(String strAttachment) {
            this.strAttachment = strAttachment;
        }

        /**
         * Gets the attachment report.
         *
         * @return the attachmentReport
         */
        public List<String> getAttachmentReport() {
            return attachmentReport;
        }

        /**
         * Sets the attachment report.
         *
         * @param attachmentReport the attachmentReport to set
         */
        public void setAttachmentReport(List<String> attachmentReport) {
            this.attachmentReport = attachmentReport;
        }



        public String getRevisionName() {
            return revisionName;
        }


        public void setRevisionName(String revisionName) {
            this.revisionName = revisionName;
        }



        /**
         * @return the reviewer
         */
        public String getReviewer() {
            return reviewer;
        }


        /**
         * @param reviewer the reviewer to set
         */
        public void setReviewer(String reviewer) {
            this.reviewer = reviewer;
        }



        /**
         * @return the reviewedOn
         */
        public String getReviewedOn() {
            return reviewedOn;
        }


        /**
         * @param reviewedOn the reviewedOn to set
         */
        public void setReviewedOn(String reviewedOn) {
            this.reviewedOn = reviewedOn;
        }


        /**
         * @return the orderId
         */
        public String getOrderId() {
            return orderId;
        }


        /**
         * @param orderId the orderId to set
         */
        public void setOrderId(String orderId) {
            this.orderId = orderId;
        }


        /**
         * @return the lstSecWinReport
         */
        public List<String> getLstSecWinReport() {
            return lstSecWinReport;
        }


        /**
         * @param lstSecWinReport the lstSecWinReport to set
         */
        public void setLstSecWinReport(List<String> lstSecWinReport) {
            this.lstSecWinReport = lstSecWinReport;
        }


        /**
         * @return the strLstSecWinReport
         */
        public String getStrLstSecWinReport() {
            return strLstSecWinReport;
        }


        /**
         * @param strLstSecWinReport the strLstSecWinReport to set
         */
        public void setStrLstSecWinReport(String strLstSecWinReport) {
            this.strLstSecWinReport = strLstSecWinReport;
        }


        /**
         * @return the uamTeamAccess
         */
        public String getUamTeamAccess() {
            return uamTeamAccess;
        }


        /**
         * @param uamTeamAccess the uamTeamAccess to set
         */
        public void setUamTeamAccess(String uamTeamAccess) {
            this.uamTeamAccess = uamTeamAccess;
        }


        /**
         * @return the errorInfo
         */
        public String getErrorInfo() {
            return errorInfo;
        }


        /**
         * @param errorInfo the errorInfo to set
         */
        public void setErrorInfo(String errorInfo) {
            this.errorInfo = errorInfo;
        }

    }

Please find the JSP Snippet where the method is called in s:checkbox and s:textarea name attribute :

<s:checkbox name="webform.checkAll(%{#attr.shrFeedbackHelperForm.groupId})" cssClass="grpCheckBox" id="idchk%{#attr.shrFeedbackHelperForm.groupId}"
                                onclick="javascript:changeColor('rowidchk%{#attr.shrFeedbackHelperForm.groupId}','idchk%{#attr.shrFeedbackHelperForm.groupId}')"></s:checkbox>

Textarea :

<s:textarea  name="webform.checkAllRemarks(%{#attr.shrFeedbackHelperForm.groupId})" style="height:50px;" rows="1" cols="20" value ="%{#variable}" id="%{#shrFeedbackHelperForm.groupId}"></s:textarea>

As per the POJO class, these setter variables are never set in Struts 2.x where its happening fine in Struts 1.x. Googling does not yield my requirements. Any help providing good pointers and suggestions will be much appreciated.

Thanks




Aucun commentaire:

Enregistrer un commentaire