Tarek Oraby:
It is rather difficult (to my mind at least) to follow what is being asked here. It would be really helpful if you could share a more complete code-example and ask the question on its basis.
Thanks Tarek, Had been lil busy with office work. didnt get time to check here. i will post the code.
The following is the sample of a hibernate model
@Id
@GeneratedValue
@ViewTableColumn(headerName = "id", hideHeader = true)
@Column(name = "id")
private long id;
@ViewTableColumn
@Column(name = "name", length = 500, nullable = false)
private String name;
@ViewTableColumn
@Column(name = "code", length = 50, nullable = false)
private String code;
The Following is my custom Annotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ViewTableColumn {
public String headerName() default "";
public boolean hideHeader() default false;
}
I am iterating the result of my view page and gonna enrich the following map with key as the fieldVariable name for eg: id, name, code and value as
Map<String, Map<String, Object>> fieldPropertiesMap = new LinkedHashMap<String, Map<String, Object>>();
My Doubt is whether the highlighted portion can be made dynamic based on the key of map like
if key is id then getId
if key is name then getName
if key is code then getCode
if (CommonLibrary.isNotEmpty(fieldPropertiesMap)) {
for (Map.Entry<String, Map<String, Object>> field : fieldPropertiesMap.entrySet()) {
if (!CommonLibrary.toBoolean(field.getValue().get(TBL_HIDE_HEADER))) {
**grid.addColumn(OfficeModel::getName).setCaption(field.getValue().get(TBL_HEADER_NAME).toString());**
}
}
}
i am planning to write a generic approach for this view table population OfficeModel will be dynamically passed from a screens UI page. this can facilitate the clicking of view link on menu can display all saved data in a grid.