public abstract EntityActions extends ActionSupport implements ModelDriven { GenericValue genericValue = new GenericValue();
// ModelDriven implementation public Object getModel() { return this.value ; }
... }
You may have a problem with your use of Maps. Because Maps aren't typed, you're going to get String[] for your values. For example, given the above Action and the following ui widget:
<ui:textfield label="hello" name="username"/>
if we enter savaki for username, then the following will be true in our action:
.... public String execute() { String values[] = (String[])this.genericValue.get("hello"); // values[0] will be 'savaki' } ...
If GenericValue has javabean style setter/getters rather than just get/put, you should be ok.
Hope this helps :)
M
Rene Gielen wrote:
Hi,
Kinda new to WW2/XWork, maybe I'm blind, so tell me if I am ;-)
Here is my problem:
We work in our database driven application with a persistence Manager that abstracts records as objects implementing Map interface - manager is OFBiz entity engine, for those who might know it...
So, if I want to edit a record and store the result back to db, I have to do always the same (web environment):
1. Prepend the edit view with an initialized currentObject (a Map) in context
2. Have a jsp with a form in which inputs are presented for the entries in the currentObject the user might change
3. Have a store action to which the form in 2. submits. Store the values changed in db again.
The form should read values out of a Map and present them in inputs, ready to be changed. But how do I manage to have them dispatched back to the / a Map for the store action, including type conversion???
What I tried till now
EntityAction.java:
public abstract class EntityActions extends ActionSupport {
protected GenericValue currentObject = null; //GenericValue implements Map
public void setCurrentObject(GenericValue object) {..}
public GenericValue getCurrentObject() {..}
...
public String edit () { // load some GenericValue from db // or create an empty one and set it as currentObject .. return SUCCESS; }
public String store () { // store the currentObject, which now should contain the edited // values from our web form .. if (noError) { return SUCCESS; } else { // Do input again to correct values return INPUT; } } }
xwork.xml:
...
<action name="edit" class="de.aixcept.tse.action.EntityActions" method="edit"
<param name="entity">translations</param> <result name="success" type="dispatcher"> <param name="location">/WEB-INF/jsp/admin/translation/edit.jsp</param> </result> <interceptor-ref name="defaultStack"/> </action>
<action name="store" class="de.aixcept.tse.action.EntityActions" method="store" >
<param name="entity">translations</param>
<result name="input" type="dispatcher">
<param name="location">/WEB-INF/jsp/admin/translation/edit.jsp</param>
</result>
<result name="success" type="chain">
<param name="actionName">edit</param>
</result>
<interceptor-ref name="defaultStack"/>
</action>
...
edit.jsp:
..
<ww:form action="store.action" method="POST" >
<ww:textfield label="English :" name="???" value="#currentObject.get('en')" />
<ww:textfield label="German :" name="???" value="#currentObject.get('de')" />
<ww:submit name="storeTrans" />
</ww:form>
..
I hope I could explain what I mean...
Is it possible to dispatch the form parameters back again to currentObject for store action, including type conversion? Such as
Action:
private Long myNumber = null;
public Long getMyNumber()
public void setMyNumber(Long aNumber)
...
form: <ww:textfield label="My Number :" name="myNumber" />
...
which will do everything automagically when parameters interceptor is in place?
Can someone help (if anyone understood what I try to do :-) ??
Regards, Rene
------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork