You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mahabir Gupta <ma...@gmail.com> on 2024/03/06 07:06:43 UTC

Re: Radio button selection is not being saved on the front end

Hi,

I have some radio button where I can select one radio button at a time and
safe it. It is being saved in the database but on the frontend it is not
being saved.

public class getDotsCarRentalAction extends GenericMappingDispatchAction{

    public String saveCr(){
        HttpSession session = request.getSession();
        String result = null;
        DotsCarRentalForm frm = null;
        DotsCarRental dotsCarRental = new DotsCarRental();
        dotsCarRental = (DotsCarRental)
session.getAttribute(DBConstants.sessionCarId);
        frm = (DotsCarRentalForm) form;
        dotsCarRental = frm.getFormData(dotsCarRental);
        result = frm.getFctSelected().trim();

        if(result == null || result.length() < 1) result = "CARRENTAL";
        ActionErrors errors = frm.validate(getTextProvider(),request);
        if(errors != null){
            saveErrors(errors);
            return "CARRENTAL";
        }
        session.setAttribute(DBConstants.sessionCarId,dotsCarRental);
        return result;
    }

    public String getCr(){
        HttpSession session = request.getSession();
        DotsCarRental dotsCarRental = new DotsCarRental;
        dotsCarRental = (DotsCarRental)
session.getAttribute(DBConstants.sessionCarId);
        DotsCarRentalForm frm = new DotsCarRentalForm();
        if(dotsCarRental !=null){
            frm.setFormData(dotsCarRental);
        }
        frm.setFctSelected(null);
        frm.setValSelected(null);
        request.setAttribute("dotsCarRentalForm",frm);
        return "success";

    }
}

There is no error on the console and neither is there any error on the
developer tools on MS Edge


<div class="form-group" style="width:100%; clear: both;">
<div>Staff</div><br />
<s:iterator var="srr" value="#rr">
<span>
    <s:radio name="rentalReason" style="font-weight: normal; padding:
2px; word-wrap: break-word;" value="#frm.rentalReason" list="#srr"
listKey="lookupTitle" listValue="lookupTitle" /><br/>
</span>
</s:iterator>
</div>

<div>
    <a class="btn btn-outline-primary"
href="javascript:document.forms[0].fctSelected.value='SAVEEOTAF';document.forms[0].submit();">SAVE
AS DRAFT</a>

</div>

<!--struts-dots.xml-->
<action name="SaveDotsCarRental"
class="com.dots.action.getDotsCarRentalAction" method="saveCr">

    <!--struts-generated.xml-->
<action name="SaveDotsCarRental"
class="com.dots.action.getDotsCarRentalAction" method="saveCr">

    <!--viewDotsCarRental.jsp-->
    <form name="form" method="post" action="SaveDotsCarRental.do"
onsubmit="return false">


Please assist.
Thank you.

Regards

Mahabir

Re: Radio button selection is not being saved on the front end

Posted by Lukasz Lenart <lu...@apache.org>.
You can test 6.4.0-SNAPSHOT and confirm if this fixes the problem.
https://nightlies.apache.org/struts/snapshot/
https://struts.apache.org/builds.html#maven-snapshots


pon., 11 mar 2024 o 10:52 Mahabir Gupta <ma...@gmail.com> napisał(a):
>
> Dear Lukasz,
>
> My apologies yes I meant Struts 2.5 So this means I have to wait for Struts 6.4 before the radio button will be able to display on the frontend?
> Kindly confirm. Thank you.
>
> Regards
> Mahabir
>
> On Mon, Mar 11, 2024 at 5:29 PM Lukasz Lenart <lu...@apache.org> wrote:
>>
>> I assume you meant Struts 2.5 and I assume you have followed the migration guide
>> https://cwiki.apache.org/confluence/display/WW/Struts+2.5+to+6.0.0+migration
>>
>> And this can be related to what Nate is suggesting
>>
>> pon., 11 mar 2024 o 09:29 Mahabir Gupta <ma...@gmail.com> napisał(a):
>> >
>> > Dear Lukasz,
>> >
>> > I upgraded from Struts 2-6 to struts 6.3.0.2.
>> > Thank you.
>> >
>> > Regards
>> > Mahabir
>> >
>> > On Mon, Mar 11, 2024 at 4:05 PM Nate Kerkhofs <Na...@ikan.be> wrote:
>> >>
>> >> Łukasz,
>> >>
>> >> I think this might be related to the issue I reported in November last year which will be fixed in Struts 6.4 (https://issues.apache.org/jira/browse/WW-5365). While it's not a Boolean radio button, it does sound like this is because the value is being processed as a string literal and not as an Ognl expression.
>> >>
>> >> Cheers,
>> >>
>> >> Nate
>> >>
>> >> -----Original Message-----
>> >> From: Lukasz Lenart <lu...@apache.org>
>> >> Sent: Monday, 11 March 2024 07:23
>> >> To: Struts Users Mailing List <us...@struts.apache.org>
>> >> Subject: Re: Radio button selection is not being saved on the front end
>> >>
>> >> pon., 11 mar 2024 o 04:54 Mahabir Gupta <ma...@gmail.com> napisał(a):
>> >> > The radio button is working perfectly when using Struts2. I only did an upgrade the Struts6.3.0.2 without making any changes to the code. When using Struts6.3.0.2 the radio button issue arises. There is no change of code made.
>> >>
>> >> Could you provide more information from which version you have migrated as there is no such data in your first message?
>> >>
>> >>
>> >> Cheers
>> >> Łukasz
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>>
>>
>> --
>> Łukasz
>> mobile +48 606 323 122 http://www.lenart.org.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Radio button selection is not being saved on the front end

Posted by Lukasz Lenart <lu...@apache.org>.
I assume you meant Struts 2.5 and I assume you have followed the migration guide
https://cwiki.apache.org/confluence/display/WW/Struts+2.5+to+6.0.0+migration

And this can be related to what Nate is suggesting

pon., 11 mar 2024 o 09:29 Mahabir Gupta <ma...@gmail.com> napisał(a):
>
> Dear Lukasz,
>
> I upgraded from Struts 2-6 to struts 6.3.0.2.
> Thank you.
>
> Regards
> Mahabir
>
> On Mon, Mar 11, 2024 at 4:05 PM Nate Kerkhofs <Na...@ikan.be> wrote:
>>
>> Łukasz,
>>
>> I think this might be related to the issue I reported in November last year which will be fixed in Struts 6.4 (https://issues.apache.org/jira/browse/WW-5365). While it's not a Boolean radio button, it does sound like this is because the value is being processed as a string literal and not as an Ognl expression.
>>
>> Cheers,
>>
>> Nate
>>
>> -----Original Message-----
>> From: Lukasz Lenart <lu...@apache.org>
>> Sent: Monday, 11 March 2024 07:23
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Subject: Re: Radio button selection is not being saved on the front end
>>
>> pon., 11 mar 2024 o 04:54 Mahabir Gupta <ma...@gmail.com> napisał(a):
>> > The radio button is working perfectly when using Struts2. I only did an upgrade the Struts6.3.0.2 without making any changes to the code. When using Struts6.3.0.2 the radio button issue arises. There is no change of code made.
>>
>> Could you provide more information from which version you have migrated as there is no such data in your first message?
>>
>>
>> Cheers
>> Łukasz
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>


-- 
Łukasz
mobile +48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Radio button selection is not being saved on the front end

Posted by Mahabir Gupta <ma...@gmail.com>.
Dear Lukasz,

I upgraded from Struts 2-6 to struts 6.3.0.2.
Thank you.

Regards
Mahabir

On Mon, Mar 11, 2024 at 4:05 PM Nate Kerkhofs <Na...@ikan.be> wrote:

> Łukasz,
>
> I think this might be related to the issue I reported in November last
> year which will be fixed in Struts 6.4 (
> https://issues.apache.org/jira/browse/WW-5365). While it's not a Boolean
> radio button, it does sound like this is because the value is being
> processed as a string literal and not as an Ognl expression.
>
> Cheers,
>
> Nate
>
> -----Original Message-----
> From: Lukasz Lenart <lu...@apache.org>
> Sent: Monday, 11 March 2024 07:23
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Re: Radio button selection is not being saved on the front end
>
> pon., 11 mar 2024 o 04:54 Mahabir Gupta <ma...@gmail.com> napisał(a):
> > The radio button is working perfectly when using Struts2. I only did an
> upgrade the Struts6.3.0.2 without making any changes to the code. When
> using Struts6.3.0.2 the radio button issue arises. There is no change of
> code made.
>
> Could you provide more information from which version you have migrated as
> there is no such data in your first message?
>
>
> Cheers
> Łukasz
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: Radio button selection is not being saved on the front end

Posted by Nate Kerkhofs <Na...@ikan.be>.
Łukasz,

I think this might be related to the issue I reported in November last year which will be fixed in Struts 6.4 (https://issues.apache.org/jira/browse/WW-5365). While it's not a Boolean radio button, it does sound like this is because the value is being processed as a string literal and not as an Ognl expression.

Cheers,

Nate

-----Original Message-----
From: Lukasz Lenart <lu...@apache.org> 
Sent: Monday, 11 March 2024 07:23
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: Radio button selection is not being saved on the front end

pon., 11 mar 2024 o 04:54 Mahabir Gupta <ma...@gmail.com> napisał(a):
> The radio button is working perfectly when using Struts2. I only did an upgrade the Struts6.3.0.2 without making any changes to the code. When using Struts6.3.0.2 the radio button issue arises. There is no change of code made.

Could you provide more information from which version you have migrated as there is no such data in your first message?


Cheers
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Radio button selection is not being saved on the front end

Posted by Lukasz Lenart <lu...@apache.org>.
pon., 11 mar 2024 o 04:54 Mahabir Gupta <ma...@gmail.com> napisał(a):
> The radio button is working perfectly when using Struts2. I only did an upgrade the Struts6.3.0.2 without making any changes to the code. When using Struts6.3.0.2 the radio button issue arises. There is no change of code made.

Could you provide more information from which version you have
migrated as there is no such data in your first message?


Cheers
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Radio button selection is not being saved on the front end

Posted by Mahabir Gupta <ma...@gmail.com>.
Dear Lukasz,

The radio button is working perfectly when using Struts2. I only did an
upgrade the Struts6.3.0.2 without making any changes to the code. When
using Struts6.3.0.2 the radio button issue arises. There is no change of
code made.
Thank you.

Regards
Mahabir

On Sat, Mar 9, 2024 at 10:37 PM Lukasz Lenart <lu...@apache.org>
wrote:

> śr., 6 mar 2024 o 08:08 Mahabir Gupta <ma...@gmail.com> napisał(a):
> > DotsCarRental dotsCarRental = new DotsCarRental();
> > dotsCarRental = (DotsCarRental)
> session.getAttribute(DBConstants.sessionCarId);
>
> You don't have to create an instance if in the next line you assign a
> value from session, this is enough:
>
> DotsCarRental dotsCarRental = (DotsCarRental)
> session.getAttribute(DBConstants.sessionCarId);
>
> > request.setAttribute("dotsCarRentalForm",frm);
> > <s:radio name="rentalReason" value="#frm.rentalReason" list="#srr"
> listKey="lookupTitle" listValue="lookupTitle" />
>
> You assign the form to the "dotsCarRentalForm" request attribute but
> in the value attribute you call "#frm.rentalReason" - maybe this is
> the problem.
>
>
> Cheers
> Łukasz
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Radio button selection is not being saved on the front end

Posted by Lukasz Lenart <lu...@apache.org>.
śr., 6 mar 2024 o 08:08 Mahabir Gupta <ma...@gmail.com> napisał(a):
> DotsCarRental dotsCarRental = new DotsCarRental();
> dotsCarRental = (DotsCarRental) session.getAttribute(DBConstants.sessionCarId);

You don't have to create an instance if in the next line you assign a
value from session, this is enough:

DotsCarRental dotsCarRental = (DotsCarRental)
session.getAttribute(DBConstants.sessionCarId);

> request.setAttribute("dotsCarRentalForm",frm);
> <s:radio name="rentalReason" value="#frm.rentalReason" list="#srr" listKey="lookupTitle" listValue="lookupTitle" />

You assign the form to the "dotsCarRentalForm" request attribute but
in the value attribute you call "#frm.rentalReason" - maybe this is
the problem.


Cheers
Łukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org