I've got t:select with two values - CHANNELS, WIDGETS. If I choose first one, I will display palette with all channels and hide widgets palette (both in zones), if I select second one, I will hide channels palette zone and display widgets palette zone. Both palettes are pre-selected with items loaded up from database. Both selectedWidgets, selectedChannels are annotated as @Persist. Problem is that customer wants to delete selected widgets, then switch to channels and add them, so two operations. If he then saves, deleted widgets are still there and channels are added correctly. Is this is possible to solve it?

有帮助吗?

解决方案

If I understood correctly you need to save values for both palettes on form submission. So both palettes should present on the form.

To solve this you can just hide one palette and show another on select value change. No server-side operation is needed (and zones is not needed too):

<t:select t:id="select" .../>
<t:palette id="widgets" .../>
<t:palette id="channels" .../>

And js using jquery:

var $select = $('#' + selectId);
var $widgets = $('#' + widgetsId);
var $channels = $('#' + channelsId);

$select.on('change', function() {
  if ($select.val() == 1 /* or another value corespondent to channels */) {
    $widgets.hide();
    $channels.show();
  } else {
    $widgets.show();
    $channels.hide();
  }
});

其他提示

thanks to sody, I managed to solve this issue. First main part was to get rid of zones, just to have a form with components and submit whole thing once and second main part was to trigger the javascript mentioned by sody in the right time. If I get time, I will paste my tml, java and javascript code, I am sure someone will help me to clean it up.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top