2012-11-16 9 views
5

मैं एक स्ट्रिंग से आगे और आगे वस्तुओं के संग्रह को परिवर्तित करने के लिए एक कस्टम प्रकार कनवर्टर बनाने की कोशिश कर रहा हूं। मेरे पास मेरे फॉर्म में एक टेक्स्ट एरिया है और मेरे सेव पर टेक्स्ट एरिया में प्रत्येक लाइन ब्रेक के लिए संग्रह में एक नया ऑब्जेक्ट बनाना चाहता हूं। जानकारी प्रदर्शित करते समय, मैं संग्रह में वस्तुओं के माध्यम से लूप करना चाहता हूं और इसे अपने टेक्स्ट क्षेत्र के लिए लाइन ब्रेक के साथ एक स्ट्रिंग में बदलना चाहता हूं। अब तक, मैं अपने कनवर्टर को आग लगने में असमर्थ हूं या मेरे पास एनोटेशन के आधार पर किसी प्रकार की त्रुटियां प्राप्त करने में असमर्थ हूं। नीचे मेरी कक्षा परिभाषा है:स्ट्रूट्स 2 एक्शन टाइप एनोटेशन का उपयोग करके सूची का रूपांतरण

@Conversion() 
public class FormsEdit extends JWebCrud{ 

इस वर्ग के अंदर मैं एक सूची है:

private Set<Formfieldopts> formfieldoptses = new HashSet<Formfieldopts>(0); 

@TypeConversion(converter = "com.webexchange.actions.tpa.setup.forms.FormFieldOptsConverter") 
public void setFormfieldoptses(Set<Formfieldopts> formfieldoptses) { 
    this.formfieldoptses = formfieldoptses; 
} 

कोई मुझे पर केंद्रित करें कर सकते हैं:

private List<Formfield> formFields; 

Formnfield वर्ग के अंदर मैं एक सेट है कनवर्टर को आग लगाने के लिए इन एनोटेशन को सही तरीके से कैसे सेट करें?

Struts 2 संस्करण: 2.2.1

Struts इंटरसेप्टर ढेर:

  <interceptor-stack name="stackWithSecurity"> 
          <interceptor-ref name="closeHibernateSession" /> 
      <!--catches exceptions pre or post action class--> 
      <interceptor-ref name="exceptionInterceptor" /> 
      <interceptor-ref name="security"> 
       <param name="excludeMethods">executeNoSecurity,executeNoSecurityOrValidation</param> 
      </interceptor-ref> 
      <interceptor-ref name="alias" /> 
      <interceptor-ref name="servletConfig" /> 
      <!-- Puts HTTPResponse and HTTPRequest objects on the action --> 
      <interceptor-ref name="openHibernateSession" /> 
      <!-- Opens a db connection and creates a hibernate session --> 
      <interceptor-ref name="prepare" /> 
      <interceptor-ref name="checkbox" /> <!-- Sets unchecked values into the action with a value of 'false' --> 
      <interceptor-ref name="params" /><!-- Sets the parameters from the HTTP request to the action --> 
      <interceptor-ref name="staticParams" /> 
      <interceptor-ref name="conversionError" /> 
      <!-- adds a field error when the value can't be converted to the right type --> 
      <interceptor-ref name="chain"> 
       <!-- these properties should not be copied from one action to another on a chain --> 
       <param name="excludes">dao</param> 
      </interceptor-ref> 
      <interceptor-ref name="validation"> 
       <param name="excludeMethods"> 
        input,back,cancel,browse,delete,executeNoValidation,executeNoSecurityOrValidation,edit 
       </param> 
       <param name="validateAnnotatedMethodOnly">true</param> 
      </interceptor-ref> 
      <interceptor-ref name="workflow"> 
       <param name="excludeMethods"> 
        input,back,cancel,browse,delete,executeNoValidation,executeNoSecurityOrValidation,edit 
       </param> 
      </interceptor-ref> 
     </interceptor-stack> 

कार्रवाई मैपिंग:

 <action name="formsSave" 
     class="com.webexchange.actions.tpa.setup.forms.FormsEdit" 
     method="save"> 
     <result name="success">/jsp/centers/tpa/setup/forms/EditForms.jsp 
     </result> 
     <result name="input">/jsp/centers/tpa/setup/forms/EditForms.jsp 
     </result> 
    </action> 
+1

एस 2 संस्करण? एक्शन/इंटरसेप्टर स्टैक कॉन्फ़िगरेशन? स्कैनिंग या रूपांतरण प्रक्रिया के संबंध में DEBUG/devMode लॉग स्तर पर कुछ भी? –

+0

एस 2 संस्करण: 2.2.1 –

+0

मेरे पास devMode में स्ट्रूट्स 2 कॉन्फ़िगरेशन है। मैंने रूट लॉगर के लिए DEBUG भी चालू कर दिया। हालांकि, मुझे नहीं लगता कि स्ट्रेट्स कुछ भी आउटपुट कर रहा है। –

उत्तर

0

आपकी मदद के लिए धन्यवाद डेव। मेरा एस: टेक्स्टरेरा उस संग्रह पर इशारा नहीं कर रहा था जिसे मैं परिवर्तित करने की कोशिश कर रहा था। मैंने ऐसा करने के बाद कनवर्टर आग लगाना शुरू कर दिया। माफ करना, मेरे हिस्से पर कुल असफलता क्या है।

संबंधित मुद्दे