how to Invoking JSON Web Services with Parameters in liferay 7.4 - rest

i create a Rest service via service builder.
#AccessControlled(guestAccessEnabled = true)
#JSONWebService
public JSONObject feedback(String jsonInfo) throws SystemException, PortalException {....
after deploy, the service can be found in api/jsonws
i try invoke the service, and because the jsonInfo is very long, i cannot pass it as part of url path.
i try pass it as object, just like help doc: enter link description here
<form method="post" action="http://localhost:8080/api/jsonws/snm.record/feedback/+json-info">
<input type="hidden" name="+json-info" value="test"/>
<button type="submit" >submit</button>
</form>
the service has be called, but jsonInfo always get empty.
and if without plus(+), it is missing.
{"exception":"Missing value for parameter
json-info","throwable":"java.lang.IllegalArgumentException: Missing
value for parameter json-info","error":{"message":"Missing value for
parameter json-info","type":"java.lang.IllegalArgumentException"}}
i do not know what i missed, please help.
thanks in advance.

It could be an issue with your expected parameter type. Have you tried to change your parameter from "String jsonInfo" to "Object jsonInfo"? If you are trying to pass an object, then you may need to set that parameter to be an object.

I think you need to remove the + from the input name.

Related

How to pass props to a URL in a form with Vue.js

I'm trying to add a button that will link to a different page made to edit/delete an entry. However, the URL in the action /videos/{the id of the video}/edit
Usually I would just put it in curly braces or use a template literal, but these don't seem to be working. When I try using double curly braces /videos/{{the id of the video}}/edit I get an error saying Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead.
I'm trying to pass props for the id of the video to then apply to the URL, but I'm not sure how to go about that.
I've tried template literals, but it gives me a syntax error when I try using those in action="..." so I tried doing what it tells me to do and use binding :id="this.$props.id" but I'm not sure how to then add the id to the URL without still using interpolation.
<form method="get" :id="this.$props.id" action="/videolist/$id/edit">
<button type="submit">Edit</button>
</form>
props: ['id', 'name', 'description', 'category']
Thanks, I ended up solving it using a template literal. It just didn't work how I thought it did. This ended up working
<form method="get" :action="`/videolist/${this.$props.id}/edit`">
<button class="btn btn-success" type="submit">Edit</button>
</form>

JSF - Passing parameter between two RequestScoped Managed beans in JSF page [duplicate]

I am using JSF 2.2 on Glassfish 4.1.
I am trying to pass in a query parameter to as an action method argument as follows:
// Example 1. This does not work.
// at url http://localhost:8080/app/order.xhtml?email=test#email.com
<p:commandButton value="Place order" action="#{orderManager.placeOrder(param['email'])}" />
(Know that param is an implicit EL object.)
In the server log I have configured it to print the method parameter, but I can see that an empty string was passed-in, not "test#email.com" as I expected.
I have confirmed that my overall configuration is working. If I replace the above snippet with the following, then "test#email.com" is output in the server log:
// Example 2. This works.
<p:commandButton value="Place order" action="#{orderManager.placeOrder('test#email.com')}" />
I have also confirmed that my use of EL implicit objects is feasible. The following snippet works if I retrieve the parameter from the FacesContext (after removing the email parameter from placeOrder's signature, of course):
// Example 3. This works.
<p:commandButton value="Place order" action="#{orderManager.placeOrder()}" >
<f:param name="email" value="#{param['email']}"/>
</p:commandButton>
And here is a final mystery, one that truly confuses me, if I use the following snippet, I can retrieve the "email" parameter from both the method parameter and the FacesContext, but recall that the method parameter wasn't retrievable in Example 1!
// Example 4. This works, and BOTH parameters are retrievable!
<p:commandButton value="Place order" action="#{orderManager.placeOrder(param['email'])}" >
<f:param name="email" value="#{param['email']}"/>
</p:commandButton>
Can I pass in an implicit JSF EL object as an action method parameter?
And do you have an explanation for why it seems to work in Example 4, but not Example 1?
The action attribute is evaluated during apply request values phase of the HTTP request triggered by the form submit, which is thus a different HTTP request than the one which produced the HTML output with therin the form (and having the email parameter present in the request).
The <f:param> tag is evaluated during render response phase of the HTTP request which needs to produce the HTML output with therein the form. This thus ends up "hardcoded" in the generated HTML output (on contrary to the EL method arguments in the action attribute!). When the user submits the form, this just gets passed back to the server as a plain vanilla String request parameter (which you would need to convert back if it was originally a complex type).
This has got nothing to do with whether the value is an implicit EL object or not.
That said, there are 2 other ways:
Pass it as hidden input (no, not with <h:inputHidden>).
<h:form>
<input type="hidden" name="email" value="#{param.email}" />
...
</h:form>
Set it as property of a view scoped bean, it'll stay in bean as long as the view lives.
<f:metadata>
<f:viewParam name="email" value="#{viewScopedBean.email}" />
</f:metadata>

Customised Error Message for default DateValidator in Wicket

I'm using DateValidator class to validate the date entered by user. I'm getting generic error message for this. Can I customise the error message without creating a separate Validator class.
Yes, for example if you have the following kind of page.
MyPage.html
<wicket:page>
<form wicket:id="form">
<input type="text" wicket:id="startDate" />
<input type="text" wicket:id="endDate" />
</form>
</wicket:page>
Then you add next to your java class a properties file named MyPage.properties in which you add the following entries.
MyPage.properties
form.startDate.DateValidator.minimum=<message for minimum startDate>
form.startDate.DateValidator.maximum=<message for maximum startDate>
form.endDate.DateValidator.minimum=<message for minimum endDate>
form.endDate.DateValidator.maximum=<message for maximum endDate>
You can use variables like ${input} or ${label} to be substituted in the feedback messages.
A good place to start is in the Wiki of Apache Wicket at https://cwiki.apache.org/confluence/x/N1IB
Looking at the API Docs for DateValidator i can see that based on the condition that failed wicket used different error keys ..like : DateValidator.range, DateValidator.minimum, DateValidator.maximum. You can use this keys and create your custom error messages for this situations.

Grails object marshalling - adding data type hints?

I'd like to be able to have something like this:
<form>
<input type="date" name="params.date"/>
<input type="text" name="params.myString"/>
</form>
And marshall this to
Map<String, Object> params
['date': (Date object),
'myString': (String)]
inside of a command object holder as such:
class Holder{
def params
def unshownAttributes
}
I thought about doing some hackery involving javascript to parse out a data-type HTML5 attribute and preprending the name (and fixing up the types later), but I was hoping there was a better way to do this automatically with groovy or grails.
Any thoughts?
No such mechanism currently exists. You may save yourself some pain by just creating methods for every marshalling instance you need with proper command objects.

Html.Hidden() inserting wrong value

When I use a form html helper method in one of my views like <%=Html.Hidden("id", "some id text") %> it creates a hidden input field for me but it puts the wrong value in there.
Instead of getting
<input name="id" type="hidden" value="some id text"/>
I get
<input name="id" type="hidden" value="11000"/>
So the value is being found from somewhere else. In this case it's the primary id of the parent record. So it is an id, it's just the wrong id.
Does anyone have any ideas? I'm pretty sure this didn't happen in MVC1
Model binding always takes precedence. The model binder doesn't know of if a field is hidden. See http://forums.asp.net/t/1559541.aspx and
http://forums.asp.net/t/1703334.aspx
I can thing about following options
Value you are passing to the view is wrong, eg. data passed to view(you can check debugging in controller to see what are you passing into it
You are using ViewData and TempData data with different values which are overridden
else please put here your code so we all can see what is wrong