Fórum

custom attribute of type checkbox

Gaurav Talwar, modificado 14 Anos atrás.

custom attribute of type checkbox

New Member Postagens: 13 Data de Entrada: 05/04/10 Postagens Recentes
Hi All,

I want to add a new field of type checkbox on the create account page. I can't find checkbox type when creating custom attributes. Any ideas how to achieve this?

Thank you
Gaurav
thumbnail
Nidhi Singh, modificado 14 Anos atrás.

RE: custom attribute of type checkbox

Regular Member Postagens: 155 Data de Entrada: 07/10/09 Postagens Recentes
Hi,

you have to modify create_account.jsp.
In LR 5.2.3, custum attribute is provided only for users and organization.

Thanks
Nidhi Singh
thumbnail
Amos Fong, modificado 14 Anos atrás.

RE: custom attribute of type checkbox

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
Hi Gaurav,

The best I can figure it out is to use type Boolean and override page.jsp for custom_attribute to output a checkbox instead of a select box
Gaurav Talwar, modificado 14 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 13 Data de Entrada: 05/04/10 Postagens Recentes
Thanks for the replies!

But from what Nidhi is saying i understand that a custom attribute cannot be added on "create account" page as it can only be viewed by guests. Correct me if i am wrong!

Thank you
Gaurav
Gaurav Talwar, modificado 13 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 13 Data de Entrada: 05/04/10 Postagens Recentes
Hi Amos,

I have managed to get a select drop down with boolean values. Its in the format:


	<liferay-ui:custom-attribute className="<%= User.class.getName() %>" classPK="<%= 0 %>" editable="<%= true %>" label="<%= true %>" name="email-subscription" />


But i can't understand how a select is getting generated from above code.. Can you point me to some documentation or tell me how would i convert the above custom attribute code to checkbox?

Thanks heapsemoticon
Gaurav
thumbnail
Amos Fong, modificado 13 Anos atrás.

RE: custom attribute of type checkbox

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
Yes, it is generated in /html/taglib/ui/custom_attribute/page.jsp

You can use a jsp hook to override it.
Gaurav Talwar, modificado 13 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 13 Data de Entrada: 05/04/10 Postagens Recentes
Thanks Amos.

For the benefit of others, this is what i did:

replace the following in page.jsp


<select id="<%= randomNamespace %><%= escapedName %>" name="<portlet:namespace />ExpandoAttribute(<%= escapedName %>)">
							<option <%="curValue" ? "selected" : "" %> value="1"&gt;</option>
							<option <%="!curValue" ? "selected" : "" %> value="0"&gt;</option>
						</select>


by


<input id="<%= randomNamespace %><%= escapedName %>" type="checkbox" name="<portlet:namespace />ExpandoAttribute(<%= escapedName %>)" value="1" <%="curValue" ? "checked" : ""%>
						/&gt;


Thanks
Gaurav Talwar
thumbnail
Mati Khan, modificado 13 Anos atrás.

RE: custom attribute of type checkbox

Junior Member Postagens: 25 Data de Entrada: 01/11/10 Postagens Recentes
Hi Gaurav,

I tried to override page.jsp and add your code for input-checkbox instead of select, but it doesn't save correct value, if the box is checked or not it is saving default value in expando column.



Can you please explain how you came to fix it?
Temire Emmanuel, modificado 7 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 2 Data de Entrada: 21/02/17 Postagens Recentes
But It does not return the correct value. whether checked or not the default value is always returned
Pallavi Havale, modificado 7 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 9 Data de Entrada: 28/08/15 Postagens Recentes
Hi Amos Fong,
Could you please tell me where can I find out the page.jsp file in liferay 7.
In Liferay 7 Hook I checked with all jars ,but there also I couldn't find out the page.jsp.

Thanks In Advance,
Pallavi
thumbnail
Amos Fong, modificado 7 Anos atrás.

RE: custom attribute of type checkbox

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
I believe it's in foundation/expando/expando-taglib
thumbnail
sunil G, modificado 11 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 6 Data de Entrada: 09/12/11 Postagens Recentes
Hi Amos,


I want a custom attribute which loads all organizations(Drop Down) in user profile. Can u suggest any idea.

Thanks in advance,
Sunil
Hiral Barot, modificado 11 Anos atrás.

RE: custom attribute of type checkbox

New Member Postagens: 17 Data de Entrada: 03/01/12 Postagens Recentes
You can achieve this by following code snippet :

User user = PortalUtil.getUser(renderRequest);
List<Organization> allOrg = OrganizationLocalServiceUtil.getOrganizations(-1, -1);
String[] str = new String[allOrg.size()];
for (int i = 0; i < allOrg.size(); i++) {
str= allOrg.get(i).getName();

}
user.getExpandoBridge().setAttributeDefault("test",str); // where "test" is your custom attribute name