Search code examples
javaasposeaspose.words

AsposeX - accessing object within object


Basic Question

How do we access a variable within a variable using asposeX word template variable notation?

Description

I have the following java class structure:

    @Data
public static class MyCase {
        private User caseHandler = new User();      
    }

    @Data
   public static class User implements Serializable {
  private String fullName;
}

And I was trying the following within an AsposeX word template:

  <<foreach [c in root]>> 
  << [c.caseHandler.fullName] >> 
  <</foreach>>

But the following was failing.

Currently the below is working for me:

   <<foreach [c in root]>> 


<<foreach [in c.caseHandler]>>

<<[fullname]>>  

<</foreach>>


      <</foreach>>

Is there a more efficient way to reference fullName within c.caseHandler?


Solution

  • So the solution was mentioned by Tahir was to use first().

    There is a list of extension enumeration methods at:

    https://docs.aspose.com/display/wordsjava/Appendix+A.+Enumeration+Extension+Methods