We are using an action with ModelDriven
interface. The action has the scopedModelDriven
interceptor and we save the model in session. The model is as below:
public class Fundtransfer{
private String amount;
private String sourceAccount;
private String destinationAccount;
private String sign
//setter's and getter's ommited
}
The Fundtransfer
bean is used as a model. The JSP form has amount, sourceAcount
and destinationAcount
fields which maps to Fundtransfer
bean automatically via modelDriven
interceptor.
Every thing is normal till hear!
Of course the user can simple tramped the HTML form and pass a variable named sign
to the action and the interceptor will update it the bean.
Is it possible that we can configure a model in away that the sign value could not be updated via ModelDriven
interceptor.
I know I can create a new bean and then copy it to Fundtransfer
bean or use some sort of inheritance. Are there better ways.
The real bean which we are using is huge and also some of the has nested beans.
I thought may be I can use some aspect tricks but I don't know is it possible or not?
The
ModelDriven
bean usually used for read/write via the getters/setters. You can control access here. However, if you don't know yet Struts2 set parameters viaparams
interceptor which uses OGNL to populate the model. You can control this interceptor via parametersexcludeParams
for exampleAnother approach is to use
ParameterNameAware
where you could implement black/white list of parameters. Be careful with this approach can open door to restricted parameters by the first method.