Message Boards

« Back to 2.- Usage ( From Xml file to CRUD Portlet)

How can we view details of field type (text) when it is in View Mode

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hi Community,

With reference to One Table, Two Fields one Varchar and the other Text Example

How can we see the details of comments field (text type i,e acts as textarea field ) in View Mode. Where as in One Table, Two Fields one Varchar and the other Text Example its just shown a check box (checked if description is not null). as shown below..
Attachment

Attachments: checkbox.jpg (22.6k)

RE: How can we view details of field type (text) when it is in View Mode
Answer
12/10/11 12:24 PM as a reply to chethan dhananjaya.
Hello Chethan,

You have to touch the code, very small change in the view.jsp, but there is not automatic way of doing it today.

Using generated code from XMLPFExample06.xml go to xmlpfexampleF/docroot/JSPs/users/view.jsp and you can see code:

 1        <liferay-ui:search-container-column-text name="Comments" align="center">
 2            <%
 3                 String userCommentsIcon = iconUnchecked;
 4                String userComments = users.getUserComments();
 5                if (!userComments.equals("")) {
 6                     userCommentsIcon= iconChecked;
 7                 }
 8               %>
 9               <liferay-ui:icon image="<%=userCommentsIcon %>"/>
10        </liferay-ui:search-container-column-text>


That leads to the icon being checked or not. (see image "text_icon.jpg" below). If you change this code for:

1        <liferay-ui:search-container-column-text
2            name="Comments (text)"
3            property="userComments"
4            orderable="false"
5            orderableProperty="userComments"
6            align="left"
7        />


You will get the text from it. (see image "text.jpg" below).

If you wanted to have an option in the userComments field, about showing the icon, or showing the text, how would you write it in the xml definition?


<field>
<name>userComments</name>
<title>Comments</title>
<type>
<text></text>
</type>
<showFieldInView>true</showFieldInView>
<required>false</required>
</field>



Saludos, Jack.
Attachment

Attachment

Attachments: text.jpg (50.3k), text_icon.jpg (22.2k)

RE: How can we view details of field type (text) when it is in View Mode
Answer
1/7/13 10:09 AM as a reply to Jack A. Rider.
Hi Jack,
It looks quite good showing all the comments information.
But, What about the line breaks generated into the edit mode text field?
Is there any way to accomplish this?

Thanks,
Raúl.
Attachment

Attachment

Attachments: edit mode description.jpg (41.7k), view mode description.jpg (46.1k)

RE: How can we view details of field type (text) when it is in View Mode
Answer
1/7/13 10:31 AM as a reply to Raúl Jiménez.
  Hola Raul,

             Not sure, but I think, "liferay-ui:search-container-column-text" tag probably is "working" the display of the field. You can try with something like :

1       <liferay-ui:search-container-column-text
2            <%
3            String userComments = users.getUserComments();
4            %>
5            name="Comments (text)"
6            value="<%= userComments %>"
7        />

      use value instead of using property.

        Come back and tell us the result. emoticon

       Saludos, Jack.       

RE: How can we view details of field type (text) when it is in View Mode
Answer
1/7/13 11:40 AM as a reply to Jack A. Rider.
 Hi Jack,
I've tried this approach but I still have same results. emoticon
1   <% String productDescription = products.getProductDescription(); %> 
2   <liferay-ui:search-container-column-text
3   name="Product Description"
4   value="<%= productDescription %>"    
5   align="left"
6  />

Any other idea?

Thanks,
Raúl.

RE: How can we view details of field type (text) when it is in View Mode
Answer
1/7/13 12:18 PM as a reply to Raúl Jiménez.
 Hola Raul,

       Absolutely my fault, the issue deals with html presentation, where text file char "\n" represents new line, in html "<br/>" tag represents the new line.  So if you want to display new lines on a web page, you have to substitute one for the other. Like this:

 1  <liferay-ui:search-container-column-text
 2     <%
 3        String pepeText = pepe.getPepeText();
 4        pepeText = pepeText.replaceAll("\n", "<br/>");
 5     %>
 6
 7     name="Header of Text"   
 8     value="<%= pepeText %>"
 9     align="left"
10   />

      Result:
Attachment

Attachments: saltos_de_linea.png (11.7k)

RE: How can we view details of field type (text) when it is in View Mode
Answer
1/7/13 12:38 PM as a reply to Jack A. Rider.
Hola Jack,
Good news, it works absolutly atomic. ;)
It's good to know that every html issue can be resolved at JSP layer.
Shoudn't this approach be resolved by liferay at taglib layer?

Thanks and best regards,
Raúl.