You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by "Robert G." <ga...@mercon24.de> on 2012/07/30 02:51:38 UTC

Problem with Primary Key String

Hello,

I refer i.ex. to ProductCategoryAttribute
There is a primary Key named "attrName" (id-long-ne, but I changed to
id-ne).

when I safe a as attrName a String like: "This String" it safes the value.
But when I want to delete this attribute, I get an error, that it is not
found. Now I realised, that when the service gets the value from database it
makes this string: "This*+*String", so it inserts a "+" instead of the
whitespace --> of course now it cannot find the corresponding
entityinstance.

How can I work arround there? I tried sth like: 
<set field="attrName" from-field="${bsh:parameters.attrName.replaceAll('+','
'}" /> 
If this would work, I do not like this solution, cause when I have to handle
lots of values, this is not a nice work around. 

Has PK Fields have to be a single string? Cause I wanted to name the
attribute correctly, just as I show it in my eccommerce application, so if I
have to use a single string, I need to add e new column to that entity.

What would you do?

Thanks



--
View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Problem with Primary Key String

Posted by "Robert G." <ga...@mercon24.de>.
mhh, I use "CategoryScreens.xml" ... it is a backend view, not the ecommerce.
I talked about ecommerce, cause I show these values in ecommerce, but
storing, updating, or deletion is done in backend...this function is
allready ootb in ofbiz (on category --> attributes), so thats why i am
wondering.

this issue is also when I test here:
https://demo-stable.ofbiz.apache.org/catalog/control/EditCategoryAttributes?productCategoryId=200

using a "Attr Name" which has whitespaces (like "test test") than I cannot
delete --> it adds the "+" 

So I think it has nothing todo with ecommerce URL handling.

any more ideas? :) I get crazy, and I do not wana add an extra field for
primary key, but I have to use names with whitespaces.





--
View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353p4635370.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Problem with Primary Key String

Posted by Jacques Le Roux <ja...@les7arts.com>.
A just a bet here, because I have no time to look at it. I could be related to an old SEO mechanims which was using + in eCommerce 
urls prod categories and products. It's 100% a guess, and 1% sure

Jacques

From: "Robert G." <ga...@mercon24.de>
> ok, it seems, that the form data is handled different when I use a submit
> button instead of a hyperlink with paramer:
>
> <field name="submitButton" title="${uiLabelMap.CommonUpdate}"
> widget-style="smallSubmit"><submit button-type="button"/></field>
> *--> this one sends the parameter from database as they are stored...*
>
> <field name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}"
> widget-style="buttontext">
>   <hyperlink target="deleteProductCategoryAttribute"
> description="${uiLabelMap.CommonDelete}">
>        <parameter param-name="productCategoryId"/>
>        <parameter param-name="attrName"/>
>  </hyperlink>
> </field>
> *--> this method replaces whitepacese in a string with a "+"-sign. That is
> bad, how do you handle it? Cause a database request on those values will not
> get a result...*
>
>
>
>
>
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353p4635365.html
> Sent from the OFBiz - User mailing list archive at Nabble.com. 

Re: Problem with Primary Key String

Posted by "Robert G." <ga...@mercon24.de>.
ok, it seems, that the form data is handled different when I use a submit
button instead of a hyperlink with paramer:

<field name="submitButton" title="${uiLabelMap.CommonUpdate}"
widget-style="smallSubmit"><submit button-type="button"/></field>
*--> this one sends the parameter from database as they are stored...*

<field name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}"
widget-style="buttontext">
   <hyperlink target="deleteProductCategoryAttribute"
description="${uiLabelMap.CommonDelete}">                 
        <parameter param-name="productCategoryId"/>
        <parameter param-name="attrName"/>
  </hyperlink>            
</field>
*--> this method replaces whitepacese in a string with a "+"-sign. That is
bad, how do you handle it? Cause a database request on those values will not
get a result...*





--
View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353p4635365.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Problem with Primary Key String

Posted by "Robert G." <ga...@mercon24.de>.
The interesting thing is, that when I want to update (not delete) the
attribute...it works fine, but when I want delet, than it does not work,
cause of th "+"-signs.

The only difference is, that there is a hyperlink used to send the parameter
(for delete) to the service. By updating the data, there is a submit-button
in use.

what is the difference? Why in one case it add the "+" signs, and in the
other case, it does not?




Robert G. wrote
> 
> Hello,
> 
> I refer i.ex. to ProductCategoryAttribute
> There is a primary Key named "attrName" (id-long-ne, but I changed to
> id-ne).
> 
> when I safe a as attrName a String like: "This String" it safes the value.
> But when I want to delete this attribute, I get an error, that it is not
> found. Now I realised, that when the service gets the value from database
> it makes this string: "This*+*String", so it inserts a "+" instead of the
> whitespace --> of course now it cannot find the corresponding
> entityinstance.
> 
> How can I work arround there? I tried sth like: 
> <set field="attrName"
> from-field="${bsh:parameters.attrName.replaceAll('+',' '}" /> 
> but it does not work.
> If this would work, I do not like this solution, cause when I have to
> handle lots of values, this is not a nice work around. 
> 
> Has PK Fields have to be a single string? Cause I wanted to name the
> attribute correctly, just as I show it in my eccommerce application, so if
> I have to use a single string, I need to add e new column to that entity.
> 
> What would you do?
> 
> Thanks
> 




--
View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353p4635361.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Problem with Primary Key String

Posted by "Robert G." <ga...@mercon24.de>.
Ok Thank you, I will follow this advice! 





--
View this message in context: http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353p4635384.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: Problem with Primary Key String

Posted by Mike <mz...@gmail.com>.
Just a comment.  In all the years I've been dealing with databases, it was
never considered good practice (and has always been avoided) to have a
space character in any primary key, although technically it should work. It
looks like you discovered an edge case in ofbiz.  Even if you manage to
initially get it to work, there may be other places where the problem will
show up.

Maybe use an underscore (_) instead, --or-- define another entity, maybe
called 'attrDesc' that contains the spaced TEXT?

On Sun, Jul 29, 2012 at 5:51 PM, Robert G. <ga...@mercon24.de> wrote:

> Hello,
>
> I refer i.ex. to ProductCategoryAttribute
> There is a primary Key named "attrName" (id-long-ne, but I changed to
> id-ne).
>
> when I safe a as attrName a String like: "This String" it safes the value.
> But when I want to delete this attribute, I get an error, that it is not
> found. Now I realised, that when the service gets the value from database
> it
> makes this string: "This*+*String", so it inserts a "+" instead of the
> whitespace --> of course now it cannot find the corresponding
> entityinstance.
>
> How can I work arround there? I tried sth like:
> <set field="attrName"
> from-field="${bsh:parameters.attrName.replaceAll('+','
> '}" />
> If this would work, I do not like this solution, cause when I have to
> handle
> lots of values, this is not a nice work around.
>
> Has PK Fields have to be a single string? Cause I wanted to name the
> attribute correctly, just as I show it in my eccommerce application, so if
> I
> have to use a single string, I need to add e new column to that entity.
>
> What would you do?
>
> Thanks
>
>
>
> --
> View this message in context:
> http://ofbiz.135035.n4.nabble.com/Problem-with-Primary-Key-String-tp4635353.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>