Wiki source code of Development-Examples-Path Inspector
Last modified by Pascal Robert on 2010/09/13 00:33
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | First of, it's handy to add a convenience method to your "page" component to define this "list" of objects: |
| 2 | |||
| |
3.1 | 3 | {{code}} |
| |
1.1 | 4 | |
| |
3.1 | 5 | protected void addObjectToPathComponents(Object anObject, String aPageName, Object aTitle) { |
| |
1.1 | 6 | |
| |
3.1 | 7 | if ( anObject != null ) { |
| 8 | Map aMap = new HashMap(); | ||
| |
1.1 | 9 | |
| |
3.1 | 10 | aMap.put( Path.ObjectKey, anObject ); |
| 11 | aMap.put( Path.PageNameKey, aPageName ); | ||
| 12 | aMap.put( Path.TitleKey, aTitle ); | ||
| |
1.1 | 13 | |
| |
3.1 | 14 | this.pathComponents().add( aMap ); |
| |
1.1 | 15 | |
| |
3.1 | 16 | return; |
| 17 | } | ||
| |
1.1 | 18 | |
| |
3.1 | 19 | throw new IllegalArgumentException ( "Page.addObjectWithPageNameAndTitleToPath: null object."); |
| 20 | } | ||
| |
1.1 | 21 | |
| |
3.1 | 22 | {{/code}} |
| 23 | |||
| 24 | Now, in each concrete page you could initialize the path components: | ||
| 25 | |||
| 26 | {{code}} | ||
| 27 | |||
| 28 | protected void initPathComponents() | ||
| 29 | { | ||
| 30 | Envelope anEnvelope = this.value(); | ||
| 31 | Date aDate = anEnvelope.creationDate(); | ||
| 32 | List aList = anEnvelope.list(); | ||
| 33 | |||
| 34 | this.addObjectToPathComponents( aDate, "Timeline", "TIMELINE" ); | ||
| 35 | this.addObjectToPathComponents( aDate ); | ||
| 36 | |||
| 37 | if ( aList != null ) | ||
| 38 | { | ||
| 39 | this.addObjectToPathComponents( aList ); | ||
| 40 | } | ||
| 41 | |||
| 42 | this.addObjectToPathComponents( anEnvelope ); | ||
| 43 | } | ||
| 44 | |||
| 45 | {{/code}} | ||
| 46 | |||
| |
1.1 | 47 | Finally, the path component itself could look like this: |
| 48 | |||
| 49 | {{code}} | ||
| 50 | <webobject name = "IsMain"> | ||
| 51 | <webobject name = "MainLink"><webobject name = "MainLabel"></webobject></webobject> | ||
| 52 | </webobject> | ||
| |
3.1 | 53 | |
| |
1.1 | 54 | <webobject name = "IsNotMain"> |
| 55 | <webobject name = "Components"> | ||
| |
3.1 | 56 | <webobject name = "HasPrefix"> <webobject name = "Prefix"></webobject> </webobject><webobject name = "Component"></webobject> |
| |
1.1 | 57 | </webobject> |
| |
3.1 | 58 | |
| 59 | <webobject name = "HasPrefix"> <webobject name = "Prefix"></webobject> </webobject><webobject name = "LastComponent"></webobject> | ||
| |
1.1 | 60 | </webobject> |
| |
5.1 | 61 | {{/code}} |
| |
1.1 | 62 | |
| |
3.1 | 63 | {{code}} |
| |
1.1 | 64 | |
| |
3.1 | 65 | Components: WORepetition |
| 66 | { | ||
| 67 | count = count; | ||
| 68 | index = index; | ||
| 69 | }; | ||
| 70 | IsMain: WOConditional{ | ||
| 71 | condition = isMain; | ||
| 72 | }; | ||
| 73 | IsNotMain: WOConditional{ | ||
| 74 | condition = isMain; | ||
| 75 | negate = true; | ||
| 76 | }; | ||
| 77 | ainLink: WOHyperlink{ | ||
| 78 | action = getMail; | ||
| 79 | title = "get new mail"; | ||
| 80 | }; | ||
| 81 | MainLabel: SpanString{ | ||
| 82 | value = "get mail"; | ||
| 83 | isSmall = true; | ||
| 84 | isUpperCase = true; | ||
| 85 | //isBold = true; | ||
| 86 | class = "Label"; | ||
| 87 | length = 30; | ||
| 88 | }; | ||
| |
1.1 | 89 | |
| |
3.1 | 90 | HasPrefix: WOConditional{ |
| 91 | condition = hasPrefix; | ||
| 92 | }; | ||
| 93 | Prefix: WOImage{ | ||
| 94 | src = prefixUrl; | ||
| 95 | border = 0; | ||
| 96 | align = "middle"; | ||
| 97 | }; | ||
| 98 | Component: Link{ | ||
| 99 | value = component.object; | ||
| 100 | description = component.title; | ||
| 101 | altDescription = component.title; | ||
| 102 | value = component.object; | ||
| 103 | pageName = component.pageName; | ||
| 104 | isUpperCase = true; | ||
| 105 | isSmall = true; | ||
| 106 | //isBold = true; | ||
| 107 | class = "Label"; | ||
| 108 | }; | ||
| 109 | LastComponent: SpanString{ | ||
| 110 | value = lastComponentTitle; | ||
| 111 | isSmall = true; | ||
| 112 | isUpperCase = true; | ||
| 113 | //isBold = true; | ||
| 114 | class = "Label"; | ||
| 115 | length = 30; | ||
| 116 | }; | ||
| |
1.1 | 117 | |
| |
3.1 | 118 | |
| 119 | {{/code}} | ||
| 120 | |||
| |
1.1 | 121 | That's all folks. |