[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-05-04 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17339263#comment-17339263
 ] 

ASF subversion and git services commented on WW-5126:
-

Commit fe656eae21a7a287b2143fad638234314f858178 in struts's branch 
refs/heads/master from Yasser Zamani
[ https://gitbox.apache.org/repos/asf?p=struts.git;h=fe656ea ]

[WW-5126] use == instead of .equals in ModelDrivenInterceptor

due to refreshing model regardless of potential overridden Object.equals


> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.6
>
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-05-04 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17339264#comment-17339264
 ] 

ASF subversion and git services commented on WW-5126:
-

Commit cb318cdc749f40a06eaaeed789a047f385a55480 in struts's branch 
refs/heads/master from Lukasz Lenart
[ https://gitbox.apache.org/repos/asf?p=struts.git;h=cb318cd ]

Merge pull request #486 from yasserzamani/ww_5126

[WW-5126] use == instead of .equals in ModelDrivenInterceptor

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.6
>
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-28 Thread Patrice DUROUX (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17334898#comment-17334898
 ] 

Patrice DUROUX commented on WW-5126:


Hi,

First my report was about the documentation. Looking at Model Driven 
documentation, it was not very clear to me about the Struts process:. My 
thinking was that the stack (and so the push to it) was for the context of the 
view (result) and so will be done just before going to it after everything is 
done regarding the action bean. After some failures,  I went to read the Model 
Driven Interceptor documentation then. And here it was more clear to me when 
was done the push looking at the paragraph related to 
{{refreshModelBeforeResult.}} So I tried to use it but without any success.

Finally everything was very clear once looking at the interceptor code and 
noticed that the refresh is based on equals() which will never help in my case 
where the model object pushed on the top of the stack before the call to the 
action execute() is partially feed by the client query (mainly its id property) 
and this object will then not be replaced by the other one given by the merge 
after the action execution. The two objects are equals based on their id (as a 
JPA manner) and the merged object will not refresh the one at the stack top.

So to remove extra  in lot of views, I have implemented 
an interceptor to solve this on my side and simplified these views.

Thanks

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.5.27, 2.6
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-28 Thread Aleksandr Mashchenko (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17334515#comment-17334515
 ] 

Aleksandr Mashchenko commented on WW-5126:
--

Also I'm not sure what inconsistency you are refereeing to. Can you be more 
specific.

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.5.27, 2.6
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-28 Thread Aleksandr Mashchenko (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17334513#comment-17334513
 ] 

Aleksandr Mashchenko commented on WW-5126:
--

What is the issue with comparing by using equals?

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.5.27, 2.6
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-27 Thread Patrice DUROUX (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17332979#comment-17332979
 ] 

Patrice DUROUX commented on WW-5126:


Hi,

My case may be summarize like the following:
{code:java}
public class EntityAction extends ActionSupport implements ModelDriven {
  private static final long serialVersionUID = 7393395802128656232L;

  private T model;

  @Override
  public T getModel() {
return model;
  }

  @Inject("DAO")
  private DAO dao;

  @Override
  public String execute() throws Exception {
model = dao.merge(model);
return super.execute();
  }

  public EntityAction(Class c) {
try {
  this.model = c.getConstructor(new Class[] {}).newInstance();
} catch (Exception e) {
}
  }
}

{code}
You can also think about having the ID part of the model (entity) feed by the 
query and have back the full model using dao.find() result.

I hope it helps.

Thanks!

 

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Assignee: Yasser Zamani
>Priority: Minor
> Fix For: 2.5.27, 2.6
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-25 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17331542#comment-17331542
 ] 

ASF subversion and git services commented on WW-5126:
-

Commit 509663717a955669d987ebd3792a0049145a235f in struts's branch 
refs/heads/ww_5126_2_5 from Yasser Zamani
[ https://gitbox.apache.org/repos/asf?p=struts.git;h=5096637 ]

[WW-5126] use == instead of .equals in ModelDrivenInterceptor

due to refreshing model regardless of potential overridden Object.equals


> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Priority: Minor
> Fix For: 2.5.27, 2.6
>
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (WW-5126) inconsistancy between Model Driven and Model Driven Interceptor documentations

2021-04-22 Thread Yasser Zamani (Jira)


[ 
https://issues.apache.org/jira/browse/WW-5126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17329388#comment-17329388
 ] 

Yasser Zamani commented on WW-5126:
---

I think documents are correct. Model will be on top of the stack regardless of 
the {{refreshModelBeforeResult}} value.

Regarding second portion thanks good catch! I think so. I personally think we 
should use {{==}} i.e. reference equality in this specific case instead. But 
could you please illustrate a valid case that epitomizes that we must change to 
{{==}}? Thanks!

> inconsistancy between Model Driven and Model Driven Interceptor documentations
> --
>
> Key: WW-5126
> URL: https://issues.apache.org/jira/browse/WW-5126
> Project: Struts 2
>  Issue Type: Improvement
>Reporter: Patrice DUROUX
>Priority: Minor
>
> Hi,
>  
> The Model Driven documentation says:
> If an action class implements the interface 
> {{com.opensymphony.xwork2.ModelDriven}} then it needs to return an object 
> from the {{getModel()}} method. Struts will then populate the fields of this 
> object with the request parameters, and *this object will be placed on top of 
> the stack once the action is executed*. Validation will also be performed on 
> this model object, instead of the action. Please read about 
> [VisitorFieldValidator 
> Annotation|https://github.com/apache/struts-site/blob/master/source/core-developers/visitor-field-validator-annotation.html]
>  which can help you validate model's fields.
> where as the Model Driven Interceptor documentation says:
> h2. Parameters
>  * {{refreshModelBeforeResult}} - *set to true if you want the model to be 
> refreshed on the value stack after action execution and before result 
> execution*. The setting is useful if you want to change the model instance 
> during the action execution phase, like when loading it from the data layer. 
> This will result in {{getModel()}} being called at least twice.
>  
> Looking into the code shows that the default parameter value is false.
> Moreover the interceptor refresh process is based on call to the {{equals}} 
> method and this method may have been redefined, in a JPA context for 
> instance. The replacement is then not systematic and may not be done.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)