Fórumok

Extend Organization without using custom fields?

Farrel Chen, módosítva 10 év-val korábban

Extend Organization without using custom fields?

New Member Bejegyzések: 18 Csatlakozás dátuma: 2011.04.20. Legújabb bejegyzések
I need to extend Organization, to add a new field Email_Domain, and make it appear in the "edit organization" interface in control panel.

A nature way to do so is using custom fields, which is very straightforward. However, my manager demands that this be implemented by service builder (building an additional database table) and he doesn't like custom fields at all (for some reasons, one of which being that if we move away from Liferay, the custom fields would be useless but a database table can be ported to whatever new system we're going to use).

Now creating the database table(s) and mapping Java classes via service builder is very easy. However, I don't know how to integrate the new field into the "edit organization" interface, such that when a user click at "submit", the new field would be picked up and updated to database. Is there some documentation which I could refer to?

Any suggestion would be appreciated. Thanks!
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: Extend Organization without using custom fields?

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
First your manager is wrong. if you moved away from LR, the separate table you have is still a FK to the Liferay organization which you don't have.

That said, you'll need to deploy your service jar either globally or into the ROOT/WEB-INF/lib dir to make the service layer available to Liferay. Second, you would do a hook for the enterprise JSP to include the field and handle the display, validation, etc. Finally, you'd probably also need to hook the struts action to persist your special entity through your service layer.

It's certainly all doable. Note that there are reasons not to use expandos that are valid; there is a tipping point where having too many custom fields for an entity result in too much database activity that outweighs the cost in the custom entity approach, but often times it is a suitable way to go for most Liferay extensions.
Farrel Chen, módosítva 10 év-val korábban

RE: Extend Organization without using custom fields?

New Member Bejegyzések: 18 Csatlakozás dátuma: 2011.04.20. Legújabb bejegyzések
Thank you David! I don't buy the "move away from Liferay" reason, either. If that really happens, the biggest cost wouldn't be the expando tables (a few lines of sql should re-create it), but all the Liferay relevant JSPs, Java codes and configurations.

I understand how to display the extra field (I'm gonna to add a separate JSP for it and add it under the "Organization Information" menu section). What puzzles me is that if I don't want to add a separate submit button for the jsp, but let it be part of the whole "edit organization" form and share the "Save" button, how could I tell the "Save" button that it should pick up this extra field and submit it to corresponding struts function (which I certainly need to override to persist the field).

I'm studying Liferay's source code now, since I couldn't find any documentation showing how to do that...
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: Extend Organization without using custom fields?

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
you're probably going to want to override the struts action for the save on the org. invoke the legacy action, then add your logic to handle the save of your new attributes.