Fórumok

Custom Fields

X Man, módosítva 12 év-val korábban

Custom Fields

Junior Member Bejegyzések: 41 Csatlakozás dátuma: 2012.01.05. Legújabb bejegyzések
Hello Every one:
I use Liferay 6.1, I try to get custom fields of Journal Article in Asset Publisher portlet(full_content.jsp) and I tried this code:

JournalArticleResource journalArticleResource = JournalArticleResourceLocalServiceUtil.getArticleResource(assetEntry.getClassPK());

JournalArticle journalArticle =
JournalArticleLocalServiceUtil.getArticle(assetEntry.getGroupId(), journalArticleResource.getArticleId());
ExpandoBridge value1 = (ExpandoBridge)journalArticle.getExpandoBridge().getAttribute("comboBox");

But I got this exception:


Stacktrace:
11:47:30,846 ERROR [IncludeTag:154] java.lang.ClassCastException: [Ljava.lang.St
ring; cannot be cast to com.liferay.portlet.expando.model.ExpandoBridge
at org.apache.jsp.html.portlet.asset_005fpublisher.display.full_005fcont
ent_jsp._jspService(full_005fcontent_jsp.java:850)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:432)


Thank you in advance
X Man, módosítva 12 év-val korábban

RE: Custom Fields

Junior Member Bejegyzések: 41 Csatlakozás dátuma: 2012.01.05. Legújabb bejegyzések
Hello Every one.
I think problem solved, the solution is here.
http://prideafrica.blogspot.com/2007/01/javalangclasscastexception.html

Thank you.
thumbnail
Mayur Patel, módosítva 12 év-val korábban

RE: Custom Fields

Expert Bejegyzések: 358 Csatlakozás dátuma: 2010.11.17. Legújabb bejegyzések
ExpandoBridge value1 = (ExpandoBridge)journalArticle.getExpandoBridge().getAttribute("comboBox");


journalArticle.getExpandoBridge().getAttribute("comboBox"); -> this will return value of your custom attribute 'comboBox' as String
so why r u casting it to ExpandoBridge??

you can simply use this,

String value=(String)journalArticle.getExpandoBridge().getAttribute("comboBox");


Thanks
X Man, módosítva 12 év-val korábban

RE: Custom Fields

Junior Member Bejegyzések: 41 Csatlakozás dátuma: 2012.01.05. Legújabb bejegyzések
Thank you Mayur Patel.
I see your posts in this link http://www.liferay.com/community/forums/-/message_boards/message/10023299
and it helped me greatly.
But this code:
journalArticle.getExpandoBridge().getAttribute("comboBox");
return Array of Strings (String[]), So I have to do this:
String[] arrays = (String[])journalArticle.getExpandoBridge().getAttribute("comboBox");
and then you can get the value in arrays[0].

Thank you again.
thumbnail
Mayur Patel, módosítva 12 év-val korábban

RE: Custom Fields

Expert Bejegyzések: 358 Csatlakozás dátuma: 2010.11.17. Legújabb bejegyzések
Thanks for your reply XMan,

http://www.liferay.com/de/community/forums/-/message_boards/message/4339723

See this link, This will try to clear our doubts may be, it returns as Serializable , In your case its returning String[] because your custom-field type is defined like that,

In my case custom-field was having type 'String' so I just cast that to String but Indeed it returns as Serializable

Thanks
Krishan Kumar, módosítva 12 év-val korábban

RE: Custom Fields

New Member Bejegyzések: 16 Csatlakozás dátuma: 2012.01.18. Legújabb bejegyzések
Hi Mayur,

I need a little help on Docuemnt Lib. custom Fields. If you can help me on this, that wud save my life.

I am using Liferay 6.0.6 + tomcat 6.0.29 + MySQL 5.5.

I want to search documents in Document Library on custom Fields value. That is, I added a custom field - say "Package" - in Document Library file and added a value - say "1234"- to it.

Now when is search the Liferay portal through open search portlet, it should give me this document. Currently Open search is searching on Custom fileds in User but not on Custom Fields in Document Library.

If you can suggest any solution, plz give it step by step as I am new to Liferay.

Thanx in advance...

Krishan Kumar
Suresh Rangachari, módosítva 12 év-val korábban

RE: Custom Fields

New Member Bejegyzések: 14 Csatlakozás dátuma: 2011.12.14. Legújabb bejegyzések
Hi Mayur, Xman

I have an similar requirement .

1. I have added a custom field with Key "email-notification" . This is an Group of Text values having Default Values as Yes and No.

My scope is wit Calendar Portlet. Here when ever user ADD's an EVENT or Edit's an Event i need to send out an notification to members of the organization.

But here there is an restriction i need to send out notification to the People who have the email-notification custom field is set "Yes". Now in this context,

I am using the liferay's CalEventLocalServiceImpl class. I created an EXT and modifying the exisitng sources. I added the following code to read the Custom Attribute value whether the user is been configured with Yes or No. For that,

for(int i=0;i<users.size();i++){
//user based
ExpandoBridge expandoBridge=user.getExpandoBridge();
String sam = (String)expandoBridge.getAttribute("email-notification");
System.out.println("999999 -----SAM "+sam);

String[] defaultValue = (String[])expandoBridge.getAttributeDefault("email-notification");
System.out.println("999999 "+defaultValue[0]+" ------ "+defaultValue[1]);



String defaultValue1 = (String)expandoBridge.getAttribute("email-notification");
System.out.println("888888 "+defaultValue1);

}


I get output in console as,

( thing is i get NULL for getAttribute ("email-notification") and getAttributeDefault ("email-notifcation")-- returns default value @ index -0 as Yes and 1 as No.

But i need to get what user has selected either Yes or No by accessing Index 0th element. Any corrections to the code or suggestions would help me.

Thank You in advance.

------------------------

ORG NAME MatrixOrg
999999 -----SAM null
999999 Yes ------ No
888888 null
userName..............rangachari.suresh@gmail.com
To Address is rangachari.suresh@gmail.com
to Addrss as array rangachari.suresh@gmail.com
FROM Test Test <test@liferay.com>To "rangachari.suresh@gmail.com" <rangachari.suresh@gmail.com>subj Calendar: Event Reminder for Communications

999999 -----SAM null
999999 Yes ------ No
888888 null
userName..............sureshr@bpatech.com
To Address is sureshr@bpatech.com
to Addrss as array sureshr@bpatech.com
FROM Test Test <test@liferay.com>To "sureshr@bpatech.com" <sureshr@bpatech.com>subj Calendar: Event Reminder for Communications
System.out.println("888888 "+defaultValue1);
thumbnail
Mayur Patel, módosítva 12 év-val korábban

RE: Custom Fields

Expert Bejegyzések: 358 Csatlakozás dátuma: 2010.11.17. Legújabb bejegyzések
thumbnail
me liferay, módosítva 11 év-val korábban

RE: Custom Fields

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2011.12.14. Legújabb bejegyzések
Hi Mayur,

I could not find any thing which helps to find the selected value in the custom drop down field.
Please help me out.
Its really urgent.
thumbnail
Manali Lalaji, módosítva 11 év-val korábban

RE: Custom Fields

Expert Bejegyzések: 362 Csatlakozás dátuma: 2010.03.09. Legújabb bejegyzések
Hi,

Liferay provides below code to display custom fields on page.

<liferay-ui:custom-attributes-available className="<%= VideoManagement.class.getName() %>">
<aui:fieldset>
<liferay-ui:custom-attribute-list
className="<%= VideoManagement.class.getName() %>"
classPK="<%= (vManag != null) ? vManag.getPrimaryKey() : 0 %>"
editable="<%= true %>"
label="<%= false %>"
/>
</aui:fieldset>
</liferay-ui:custom-attributes-available>

The class name: Name of custom class. vManag is object of class
Editable specifies if the values should be editable.
If you set Label to false, no labels will be printed


For more information , refer below links:

http://www.liferay.com/web/jonas.yuan/blog/-/blogs/5866747
http://www.liferay.com/community/wiki/-/wiki/Main/How+to+use+Custom+Attributes+to+enhance+Users

Thanks,
Manali
thumbnail
me liferay, módosítva 11 év-val korábban

RE: Custom Fields

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2011.12.14. Legújabb bejegyzések
Actually I am able to add the custom attributes in the document library portlet through control panel.

Here is what I have done.
Added two drop downs in the document liberary portlet thorugh control panel.
Both are visible
Extended DLFileEntry to create the listener which will be called whenever I do some operation on the documents.
In that listener I am able to access those attributes but the problem is from set of possible values I want to find the selected value.

Please help me out.
thumbnail
Antoine Comble, módosítva 11 év-val korábban

RE: Custom Fields

Regular Member Bejegyzések: 232 Csatlakozás dátuma: 2012.09.07. Legújabb bejegyzések
Did you find any solution because i have the same problem ?
thumbnail
me liferay, módosítva 11 év-val korábban

RE: Custom Fields

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2011.12.14. Legújabb bejegyzések
Actually I have done it by Javascript.
Show two fields individually by liferay-custom-attribute tag
then cover both of them with different DIV
OneChange of First div I call Jscript method which check the value set and show and hide another div based on the value.
By this way it works for me emoticon
thumbnail
Antoine Comble, módosítva 11 év-val korábban

RE: Custom Fields

Regular Member Bejegyzések: 232 Csatlakozás dátuma: 2012.09.07. Legújabb bejegyzések
I've done the same solution as you.
It works fine !