Re: Dynamically generating multiple sets of radio buttons

2018-03-03 Thread Dave Weis
That was it! It's now putting key-value pairs in the map obtained by
getVariation and they appear when I get to the execute method.

08:19:35.682 ERROR CartAction - getVariation was called
08:19:35.698 ERROR CartAction - getVariation was called
08:19:36.086 DEBUG CartAction - cart action execute
08:19:36.086 ERROR CartAction - 13000=5600
08:19:36.086 ERROR CartAction - 2000=500

Thank you!

dave





On Sat, Mar 3, 2018 at 1:17 AM, Yasser Zamani 
wrote:

>
>
> On 2/27/2018 4:37 PM, Dave Weis wrote:
> >  > value="1500"/>HOTTER
> >  public void setVariation(HashMap variationItem){
> >
> > logger.error("setVariation was called with variations");
> >
> > for (Map.Entry entry : variationItem.entrySet()) {
> > String key = entry.getKey();
> > String value = entry.getValue();
> >
> > logger.error(key + "=" + value);
> > }
> >
> >
> >  }
> > Is my method signature incorrect? Thank you!
>
> I guess Struts wont call setVariation for e.g. variation[2000]=HOTTER.
> Instead I guess it calls getVariation().put(2000, "HOTTER"); maybe you
> should use Map for defining variation instead with java
> simple getter and setter.
>
> Regards.
>
>


Re: Action chaining not forwarding ModelDriven model properties

2018-03-03 Thread Yasser Zamani


On 2/28/2018 3:47 PM, shahzad.ismail@ wrote:
> I've debugged it a bit and able to figure out that, initially, at the start 
> of action1, request.getParamater("modelprop") is null then I set modelprop in 
> the action1 method which makes mymodel.modelprop == "something" and 
> request.getAttribute("modelprop") == "something" but the 
> request.getParameter("modelprop") remains null by the end of action1 method. 
> So when it chains to action2 method, it simply rewrites 
> request.getParameter("modelprop") value, which is *null*, back to both, 
> request.getAttribute("modelprop") and mymodel.modelprop. Am I messing up with 
> some interceptor configuration?
> I've tried it with type="redirectAction" and the problem of not passing 
> mymodel.modelprop from action1 to action2 remains.
> Any suggestions would be appreciated.

AFAIR the chain result doesn't set destination action props from
request, but in your case, it calls action1.getModel() and gets the
object then calls action2.setModel(the object).

Could you try these and see what happens:

1. Via your browser, browse action2 directly (instead of action1).
2. Try different configs like action2->action3->action1, or
action3->action1->action2, or action2->action1->action3, or
action3->action2->action1.

Regards.



Re: Struts2 login action class seems to be reused

2018-03-03 Thread Yasser Zamani


On 3/3/2018 12:37 AM, Prasanth Pasala wrote:
> I was able to replicate the issue today. Asked few users to keep logging in 
> and ran jmeter to access login page, with out putting any username or 
> password. Out of the 100 attempts 2 attempts were
> successful in getting in with out username/password. I am seeing database 
> login entries for these two. Which would happen only if a valid session is 
> not present and user has provided username/password.

Shouldn't login page being accessible always? How do you try access
login page, calling directly to jsp? Or action? How do you authenticate
that access try, via session values? Via request parameters and querying
database?

> Not sure if the behavior is a side effect of having the below lines.
> 
> request.setAttribute("struts.actionMapping", new 
> ActionMapping());   
> request.setAttribute("struts.valueStack", null);

Not these lines but I guess you may also remove more things from
forwarded request (e.g. session). Could you please print
request.toString before these lines to see what type is it? Could you
serialize request to a xml to see all values stored in that request?
Anyway, like you, I also think this issue is because of forwarding the
request from Struts1 to Struts2.

Regards.



Re: java.lang.ClassCastException: org.apache.struts2.dispatcher.mapper.ActionMapping

2018-03-03 Thread Yasser Zamani


On 3/1/2018 10:12 PM, Prasanth wrote:
> I will get back to you with the exception I was getting if you don't set the 
> valueStack to null.

No, I meant why request.setAttribute("struts.actionMapping", null) not
work there (like your request.setAttribute("struts.valueStack", null))?
Why request.removeAttribute not work there?

So I asked below 

> Could you please see what is the type of request when you receive it in 
> your second context filter? e.g. println(request.getType()) before those 
> your two lines (I could see myself but maybe it will be different from 
> your one!)
> 
> Thanks in advance!

to find out these whys :)

Thanks in advance for your reply and time.