Вопрос

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