Foren

Dynamic custom fields

thumbnail
Tonu Sri, geändert vor 11 Jahren.

Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi,

I have created two custom fields A, B two dropdowns. If a user selects A, particular B value of the selected A should be populated in B dropdown.

Please provide a solution to achieve this. I am adding these custom fields to create_account.jsp using a hook.

Thanks in advance
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
Hi,
You can use ajax for it.
for assistance, to use ajax, check this:
http://sourceforge.net/projects/ajaxjqueryportl/files/

Regards
Priyanka
thumbnail
Tonu Sri, geändert vor 11 Jahren.

RE: Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi Priyanka,

Thanks for your reply.
But my concern in how to call an action or AJAX function when user select value of custom field from the dropdown.

Thanks again:
thumbnail
Amit Doshi, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Master Beiträge: 550 Beitrittsdatum: 29.12.10 Neueste Beiträge
Hi Tonu,

You can call ajax function on "onchange" event from the Select Tag and also pass value along with it in ResourceURL and get that value in serveResource method.
Now Do required operation that you need to do and get all the required value depends on the Value you got From A and from that return string or json response.

Now iterate on JSP according to it and show value in combobox.

Hope it helps.

Thanks & REgards,
Amit Doshi
thumbnail
Tonu Sri, geändert vor 11 Jahren.

RE: Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi Amit,

I am using <liferay-ui:custom attribute> tag.
How can i call onchange on this??

Thanks:
thumbnail
Priyanka Dhingra, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Master Beiträge: 501 Beitrittsdatum: 20.12.11 Neueste Beiträge
you fetching the data for "b drop down " and "a drop down" from the database??
thumbnail
Tonu Sri, geändert vor 11 Jahren.

RE: Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi Priyanka,

I want to retrieve both dropdown values from db.
My main concern is how to use AJAX or onchange in <liferay-ui:custom-attribute> tag.


Thanks:
thumbnail
Ravi Kumar Gupta, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
Tonu, can you please share your jsp code?
thumbnail
Tonu Sri, geändert vor 11 Jahren.

RE: Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi Ravi,

I created two custom fields from UI ( group of selected values) country and region.
After that i applied hook for create_account.jsp and modified jsp with these lines:

<div class="exp-ctrl-holder">
<liferay-ui:custom-attribute
className="<%= User.class.getName() %>"
classPK="<%= 0 %>"
editable="<%= true %>"
label="<%= true %>"
name="country"
/>
</div>

<div class="exp-ctrl-holder">
<liferay-ui:custom-attribute
className="<%= User.class.getName() %>"
classPK="<%= 0 %>"
editable="<%= true %>"
label="<%= true %>"
name="region"
/>
</div>

When user will select country custom field value, Region custom field should get regions for that country from database automatically. Please help me to achieve this.

Thanks in advance
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Ravi, he just want what's already been implemented in the User Address page. I'm not sure why he's posting the question here instead of just going over and looking at the source.
thumbnail
Tonu Sri, geändert vor 11 Jahren.

RE: Dynamic custom fields

Regular Member Beiträge: 197 Beitrittsdatum: 15.04.11 Neueste Beiträge
Hi Hitoshi,

Sorry if i was not able to explain myself, but i think you misunderstood the things.

What already has been implemented, that does not contain any custom fields concept. I have seen that code also.

Suppose i want to add city custom field and want to get the value on selecting values in dropdown of state.

How can I achieve this?

are you talking about i will write my full logic as already implemented in address.jsp?
thumbnail
Amit Doshi, geändert vor 11 Jahren.

RE: Dynamic custom fields

Liferay Master Beiträge: 550 Beitrittsdatum: 29.12.10 Neueste Beiträge
Please check in the source code tomcat/webaaps/html/portlet/enterprise_admin/common/addressess.jsp(refering 6.0.11 for Liferay). It will help you.