Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FELIX-6614 WebConsole configMgr saves an empty value in list properites #212

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ String applyConfiguration( final HttpServletRequest request, final String pid, f

if ( ad.getCardinality() == 0 && ( attributeType == AttributeDefinition.STRING || attributeType == AttributeDefinition.PASSWORD ) )
{
final String value = request.getParameter( paramName );
if ( value != null
&& ( attributeType != AttributeDefinition.PASSWORD || !MetaTypeSupport.PASSWORD_PLACEHOLDER_VALUE.equals( value ) ) )
String value = request.getParameter( paramName );
value = value == null ? "" : value;
if ( attributeType != AttributeDefinition.PASSWORD || !MetaTypeSupport.PASSWORD_PLACEHOLDER_VALUE.equals( value ) )
{
props.put( propName, value );
}
Expand Down
20 changes: 18 additions & 2 deletions webconsole/src/main/resources/res/ui/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,22 @@ function navigateAfterConfigurationClose() {
return false;
}

function filterEmptySerializedKeyValues(serializedData) {
if (!serializedData) {
return '';
}
var filteredData = '';
serializedData.split('&').forEach(function (field, index, array) {
var keyValue = field.split('=');
var fieldKey = decodeURIComponent(keyValue[0]);
var fieldValue = decodeURIComponent(keyValue[1]);
if (fieldValue !== '') {
filteredData += fieldKey + '=' + fieldValue + (index === array.length - 1 ? '' : '&');
}
});
return filteredData;
}

$(document).ready(function() {
configContent = $('#configContent');
// config table list
Expand Down Expand Up @@ -674,7 +690,7 @@ $(document).ready(function() {
$.ajax({
type : 'POST',
url : pluginRoot + '/' + $(this).attr('__pid'),
data : $(this).find('form').serialize(),
data : filterEmptySerializedKeyValues($(this).find('form').serialize()),
sagarmiglani marked this conversation as resolved.
Show resolved Hide resolved
success : function () {
// reload on success - prevents AJAX errors - see FELIX-3116
if(!navigateAfterConfigurationClose()) document.location.href = pluginRoot;
Expand Down Expand Up @@ -762,4 +778,4 @@ $(document).ready(function() {
if(factoryCreate) configure(selectedPid, true);
else configure(selectedPid);
}
});
});