struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CRANFORD, CHRIS" <Chris.Cranf...@setech.com>
Subject RE: JSON & ModelDriven
Date Fri, 03 Jun 2011 13:37:38 GMT
This particular case is somewhat unique.  

It is a password reset screen and in this case, the model is a User object that is being updated.
 Depending on the selections made by the administrator in the password options screen, the
User entity is either updated with a temporary password generated by the system, a static
one time password specified by the administrator or the account set to authenticate against
a LDAP system.

The administrator can specify to 1) check a temporary password which expires at login, 2)
assign a specified password by the administrator that expires at login, or 3) authenticate
against LDAP.  In all three cases, the action is responsible for taking the values from this
form and using the security API to handle the password options accordingly and persist the
user object.

The action is where the temporary (unencrypted) password from scenario 1 is maintained.  So
under that scenario, the JSON result will serialize back out to the display this value along
with actionErrors.  Under the other two scenarios, just actionErrors gets serialized back
out so that the result handler can either display a success or failure message.

This worked in 2.1.8.1 but since upgrading to 2.2.3 it appears what is used as the basis of
the JSON serialized object is different.  And because my User object contains circular dependencies
to other User objects that describe who created or updated that User object record, the JSON
result handler is just going in infinite loops in the database trying to serialize the model
which isn't desired.

I choose to use model driven because the password options page that displays show information
such as the user's name, last login and several other user record properties along with being
initialized with the current authentication type state specified (LDAP vs Local Database).
 But I suppose I could remove the ModelDriven interface implementation and reference the User
bean directly for that to get JSON to serialize the action rather than the model unless there
is a way to revert back via a parmeter to the result handler to use the older logic from 2.1.8.1
build.

Thoughts? 

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Wednesday, June 01, 2011 9:49 PM
To: Struts Users Mailing List
Subject: RE: JSON & ModelDriven


model is somehwhat analogous to the legacy struts1 formbean
action contains processing artifacts (such as public String execute())
ModelDriven more closely represents a large bean which can be serialized/deserialized as JSON
ResultType
(application/json content-type)

what does Action contain (that Model does not contan) which you want to serialize as JSON?
Martin --
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.




> Subject: JSON & ModelDriven
> Date: Wed, 1 Jun 2011 16:48:58 -0500
> From: Chris.Cranford@setech.com
> To: user@struts.apache.org
> 
> From what I have read; it appears that for an action that implements the
> ModelDriven interface that the JSON result type is going to attempt to
> serialized the model object to the JSON stream rather than the action.
> 
> Is there anyway to override this so that the action is what is returned
> instead of the model without changing the interface that the action
> implements?
> 
> Chris 
> 
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message