import com.dieutek.examsoft.entities.ExmAnswers;
import com.dieutek.examsoft.entities.ExmQuestion;
import com.dieutek.examsoft.implementors.AnswerImplementor;
import com.dieutek.examsoft.implementors.QuestionImplementor;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

public class UpdateQuestionAction extends ActionSupport implements
ServletRequestAware {

    int adminid;
    int mQuestionid;
    int mAnswerid;
    private int courseid;
    private int subjectid;
    private String question;
    private String optionA;
    private String optionB;
    private String optionC;
    private String optionD;
    private String optionE;
    private String optionF;
    private String optionG;
    private int answerType;
    private String CorrectAnswer;
    private int showAsMCQ;
    private String hint;
    HttpServletRequest request;

    public int getAdminid() {
        return adminid;
    }

    public void setAdminid(int adminid) {
        this.adminid = adminid;
    }

    public int getmQuestionid() {
        return mQuestionid;
    }

    public void setmQuestionid(int mQuestionid) {
        this.mQuestionid = mQuestionid;
    }

    public int getmAnswerid() {
        return mAnswerid;
    }

    public void setmAnswerid(int mAnswerid) {
        this.mAnswerid = mAnswerid;
    }

    public int getCourseid() {
        return courseid;
    }

    public void setCourseid(int courseid) {
        this.courseid = courseid;
    }

    public int getSubjectid() {
        return subjectid;
    }

    public void setSubjectid(int subjectid) {
        this.subjectid = subjectid;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getOptionA() {
        return optionA;
    }

    public void setOptionA(String optionA) {
        this.optionA = optionA;
    }

    public String getOptionB() {
        return optionB;
    }

    public void setOptionB(String optionB) {
        this.optionB = optionB;
    }

    public String getOptionC() {
        return optionC;
    }

    public void setOptionC(String optionC) {
        this.optionC = optionC;
    }

    public String getOptionD() {
        return optionD;
    }

    public void setOptionD(String optionD) {
        this.optionD = optionD;
    }

    public String getOptionE() {
        return optionE;
    }

    public void setOptionE(String optionE) {
        this.optionE = optionE;
    }

    public String getOptionF() {
        return optionF;
    }

    public void setOptionF(String optionF) {
        this.optionF = optionF;
    }

    public String getOptionG() {
        return optionG;
    }

    public void setOptionG(String optionG) {
        this.optionG = optionG;
    }

    public int getAnswerType() {
        return answerType;
    }

    public void setAnswerType(int answerType) {
        this.answerType = answerType;
    }

    public String getCorrectAnswer() {
        return CorrectAnswer;
    }

    public void setCorrectAnswer(String CorrectAnswer) {
        this.CorrectAnswer = CorrectAnswer;
    }

    public int getShowAsMCQ() {
        return showAsMCQ;
    }

    public void setShowAsMCQ(int showAsMCQ) {
        this.showAsMCQ = showAsMCQ;
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }

    public UpdateQuestionAction() {
    }

    public String updateQuestion() {
        QuestionImplementor qi = new QuestionImplementor();
        AnswerImplementor ai = new AnswerImplementor();
        System.out.println("Answer Id : " + getmAnswerid());
        System.out.println("Question Id : " + getmQuestionid());
        adminid = ((Integer)
request.getSession().getAttribute("adminid")).intValue();
        ExmQuestion eqn = new ExmQuestion();
        ExmAnswers eas = new ExmAnswers();
        eqn.setQuestionid(getmQuestionid());//(getmQuestionid());
        eqn.setQuestion(getQuestion());
        eqn.setCourseid(getCourseid());
        eqn.setSubjectid(getSubjectid());//eq.setSubjectid(getSubjectids());
        eqn.setAdminid(adminid);
        eqn.setOccurance(0);
        eqn.setQuestionhint(getHint());
        eqn.setShowasMcq(getShowAsMCQ());
        if (qi.editQuestion(eqn)) {
            eas.setAnswerid(getmAnswerid());//(getmAnswerid());
            eas.setAnswer(getCorrectAnswer());
            eas.setOptionA(getOptionA());
            eas.setOptionB(getOptionB());
            eas.setOptionC(getOptionC());
            eas.setOptionD(getOptionD());
            eas.setOptionE(getOptionE());
            eas.setOptionF(getOptionF());
            eas.setOptionG(getOptionG());
            if (ai.editAnswer(eas) != true) {
                addActionError("Failed to Update Answer");
            }
        } else {
            addActionError("Failed to Update Question");
        }
        addActionMessage("Question Updated Successfully");
        return SUCCESS;
    }

    @Override
    public void setServletRequest(HttpServletRequest hsr) {
        this.request = hsr;
    }
}



On Sun, Jun 15, 2014 at 2:05 PM, Lukasz Lenart <lukaszlen...@apache.org>
wrote:

> Can you show your action? Looks like a issue with setters
>
> 2014-06-14 14:57 GMT+02:00 NIJO GEORGE <nijo...@gmail.com>:
> >  <s:hidden value="%{#qa.questionid}" name="mQuestionid" id="qid" />
> >  <s:hidden value="%{#qa.answerid}" name="mAnswerid" id="aid" />
> >
> > 17:58:54,084 ERROR
> > [com.opensymphony.xwork2.interceptor.ParametersInterceptor]
> > (http--127.0.0.1-8080-6) Developer Notification (set struts.devMode to
> false
> > to disable this message):
> > Unexpected Exception caught setting 'mAnswerid' on 'class
> > com.dieutek.examsoft.question.CreateQuestionAction: Error setting
> expression
> > 'mAnswerid' with value ['26', ]
> >
> > 17:58:54,085 ERROR
> > [com.opensymphony.xwork2.interceptor.ParametersInterceptor]
> > (http--127.0.0.1-8080-6) Developer Notification (set struts.devMode to
> false
> > to disable this message):
> > Unexpected Exception caught setting 'mQuestionid' on 'class
> > com.dieutek.examsoft.question.CreateQuestionAction: Error setting
> expression
> > 'mQuestionid' with value ['3402', ]
> >
> >
> > I'm Getting the above error while getting value from two Hidden Fields
> into
> > a form Action. I have also tried these two fields with textfield too. But
> > Getting the same error.
> > I'm not using any Model driven Interface in my action. How i should
> proceed
> > with this?
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


-- 
NIJO GEORGE P
Follow me on Twitter <http://www.twitter.com/nijogeorgep>
Add me as Friend <http://www.facebook.com/nijogeorgep>
View my Profile on LinkedIn <http://in.linkedin.com/in/nijogeorgep>
+918089699703

Reply via email to