1
14
15 package com.liferay.taglib.ui;
16
17 import com.liferay.portal.kernel.dao.search.ResultRow;
18
19 import java.util.List;
20
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.JspTagException;
23
24
30 public class SearchContainerColumnScoreTag extends SearchContainerColumnTag {
31
32 private static final String DEFAULT_NAME = "score";
33
34 public int doEndTag() {
35 try {
36 SearchContainerRowTag parentTag =
37 (SearchContainerRowTag)findAncestorWithClass(
38 this, SearchContainerRowTag.class);
39
40 ResultRow row = parentTag.getRow();
41
42 if (index <= -1) {
43 index = row.getEntries().size();
44 }
45
46 row.addScore(index, getScore());
47
48 return EVAL_PAGE;
49 }
50 finally {
51 index = -1;
52 _name = DEFAULT_NAME;
53 _score = 0;
54 }
55 }
56
57 public int doStartTag() throws JspException {
58 SearchContainerRowTag parentRowTag =
59 (SearchContainerRowTag)findAncestorWithClass(
60 this, SearchContainerRowTag.class);
61
62 if (parentRowTag == null) {
63 throw new JspTagException(
64 "Requires liferay-ui:search-container-row");
65 }
66
67 if (!parentRowTag.isHeaderNamesAssigned()) {
68 List<String> headerNames = parentRowTag.getHeaderNames();
69
70 headerNames.add(_name);
71 }
72
73 return EVAL_BODY_INCLUDE;
74 }
75
76 public float getScore() {
77 return _score;
78 }
79
80 public void setScore(float score) {
81 _score = score;
82 }
83
84 private String _name = DEFAULT_NAME;
85 private float _score;
86
87 }