kind of got a fix.

here is my jsp content.

        <tr>
        <s:iterator value="columnLabels" var="label">
                <th><s:property value='label' /></th>
        </s:iterator>
        </tr>
        <s:iterator value="results" var="auditViewBean" >
        
        <tr>
         <s:iterator value="propertyList" var="auditProperty">
          <s:set var="keyName" value="key"></s:set>
          <s:iterator value="columnLabels" var="label1">
          
            <s:if test= "%{#label1== #keyName}" >           
                <td><s:property value="value.newValue" /></td>
                </s:if>
</s:iterator>
                </s:iterator>
                
        </tr>
        </s:iterator>




mahanare wrote:
> 
> Hi, I need help in resolving type conversion issue in struts 2.
> 
> Here is my problem definition.
> 
> I have a structs 2 action class called AuditTrailAction.
> Here is the class definition. It contains a List<AuditView> I have given
> my AuditView bean definition below.
> 
> Action contains a List which intern contains a bean containing a Map of
> another bean. 
> 
> I need to display this data into a tabular structure in jsp page. 
> 
> List<AuditView>, each AuditView bean contains Map<Auditproperty> and
> AuditProperty bean contains couple of properties.
> 
> for each AuditView bean in the list, I need to iterate through all the
> AuditProperty beans and display their properties into a row (html table
> row).
> 
> I have been spending time whole day today with no luck. it looks like
> there is some type conversion issue here. I went through
> http://struts.apache.org/2.x/docs/type-conversion.html, but not getting a
> solution for my scenario which looks little complex. 
> 
> Please help me!
> Thanks
> harinath
> 
> 
> 
> public class AuditTrailAction extends ActionSupport implements
> RequestAware {
>       private List<AuditView> results;
>       private int pageSize = 20;
>       private int page;
>       private AuditLogDao auditLog;
>       private Map request;
>       private String entity;
>       private String pk;
>       private List<String> columnLabels;
> 
>       public List<String> getColumnLabels() {
>               return columnLabels;
>       }
> 
>       public void setColumnLabels(List<String> columnLabels) {
>               this.columnLabels = columnLabels;
>       }
> 
>       public int getPage() {
>               return page;
>       }
> 
>       public void setPage(int page) {
>               this.page = page;
>       }
> 
>       public String getEntity() {
>               return entity;
>       }
> 
>       public void setEntity(String entity) {
>               this.entity = entity;
>       }
> 
>       public String getPk() {
>               return pk;
>       }
> 
>       public void setPk(String pk) {
>               this.pk = pk;
>       }
> 
>       public void setAuditLog(AuditLogDao auditLog) {
>               this.auditLog = auditLog;
>       }
> 
>       public List<AuditView> getResults() {
>               return results;
>       }
> 
>       public void setResults(List<AuditView> results) {
>               this.results = results;
>       }
> 
>       public String execute() {
>               
>               try {
>                       results = auditLog.getAuditTrialView(page, pageSize, 
> entity, pk);
>                       columnLabels = new ArrayList<String>();
>                       
>                       if (results != null && results.size() != 0) {
>                               AuditView view = results.get(0);
>                               Map<String, AuditProperty> mapProperties = 
> view.getPropertyList();
>                               Set<String> properties = mapProperties.keySet();
>                               for (String prop : properties) {
>                                       columnLabels.add(prop);
>                               }
>                       }
>               } catch (AuditException e) {
>                       e.printStackTrace();
>               } catch (Exception e) {
>                       e.printStackTrace();
>               }
>               
>               /*
>                * try {
>                * 
>                * results =auditLog.getAuditTrialInfo(page, pageSize); //
>                * request.put("results", results); } catch (AuditException e) 
> { // TODO
>                * Auto-generated catch block e.printStackTrace(); }
>                */
>               return SUCCESS;
> 
>       }
> 
>       public void setRequest(Map<String, Object> request) {
>               // TODO Auto-generated method stub
>               this.request = request;
>       }
> 
> }
> 
> 
> 
> @SuppressWarnings("serial")
> public class AuditView implements Serializable {
>       
>       private Map<String,AuditProperty> propertyList;// = new
> ArrayList<AuditProperty>();
> 
>       public Map<String, AuditProperty> getPropertyList() {
>               if(propertyList ==null)
>               {
>                       propertyList = new HashMap<String, AuditProperty>();
>               }
>               return propertyList;
>       }
> 
>       public void setPropertyList(Map<String, AuditProperty> propertyList) {
>               this.propertyList = propertyList;
>       }
> 
> }
> 
> And AuditProperty bean
> 
>  */
> @SuppressWarnings("serial")
> public class AuditProperty implements Serializable {
>       
>       private static final Log logger = 
> LogFactory.getLog(AuditProperty.class);
>       private String oldValue;
>       private String newValue;
>       private boolean updateFlag;
>       
>       
>       
>       public boolean isUpdateFlag() {
>               return updateFlag;
>       }
>       public void setUpdateFlag(boolean updateFlag) {
>               this.updateFlag = updateFlag;
>       }
>       public String getOldValue() {           
>               return oldValue;
>               
>       }
>       public void setOldValue(String oldValue) {
>               this.oldValue = oldValue;
>       }
>       public String getNewValue() {
>               return newValue;
>       }
>       public void setNewValue(String newValue) {
>               this.newValue = newValue;
>       }
>       public String toString()
>       {
>               String value= oldValue + " : " + newValue + " : " + updateFlag;
>               logger.debug(value);
>               return value;
>       }
> 

-- 
View this message in context: 
http://www.nabble.com/Struts-2-Type-conversion-tp22700624p22703515.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to