I am using this code. Which is working very good.
<window id="win" xmlns:w="http://www.zkoss.org/2005/zk/client" apply='MyComposer'>
<textbox value="#{$composer.student.name}"/>
But i want to use something like this
<cell width='$composer.fullWidth?"70%":"50%"'>
In my composer I have a boolean fullWidth with the proper getter but I cannot reference it with the composer. I have tried a lot but nothing seems to work.
I have try
<cell width='#{$composer.fullWidth}?"70%":"50%"'>
<cell width='{$composer.fullWidth}?"70%":"50%"'>
<cell width='#{composer.fullWidth}?"70%":"50%"'>
Another question: if I have a code like this:
<textbox id='test' if='expression'/>
How can I the or use the if using Java code? Is it not possible?
Something like:
test.setIf(boolean???????)
First of all, please use correct MVVM.
The #{} is a buggy version from zk6.0 to created MVVM.
You even can't find that back in the ZK documentation!
With real MVVM :
#load(vm.fullwidth?'70%':'50%')
Second question:
The if attribute a special one. Only static binding works here because if it's evaluated false, the component will not been rendered in the DOM.
So either use visible, or use in javacode an extra check if you may add this component to the DOM.
Related
I am migrating some JSP files to Thymeleaf and I have found the following problem. In the original JSP code there is a file that is included in lots of other JSP files that has a line like the following:
<c:set var="myVar" value="data-x=50 data-y=37" />
In the files which include this one the variable myVar is used like this:
<div class="myClass" ${myVar}>
setting several attributes that are used everywhere all at once. The main point here is that you set up myVar in one file and its values are used in all other files. If you need to change the value of the attributes you only need to change one file.
Trying to replicate this in Thymeleaf, I tried using the th:attr attribute in the following way. First, I set a variable in the model like this:
model.addAttribute("myVar", "data-x=50, data-y=37");
and then in Thymeleaf I do:
<div class="myClass" th:attr="${myVar}" >
but it does not work, it throws
TemplateProcessingException: Could not parse as assignation sequence: "${myVar}"
I've also have thought of using Javascript to add the attributes dynamically using JQuery, but I would prefer to do it in other way, since I did not built the application, it has a lot of scripting and I fear doing it through Javascript can have side effects.
Is there any way I can write directly in the HTML output using Thymeleaf?
One way you can accomplish this with preprocessing. Something like this will work with your example:
<div class="myClass" th:attr="__${myVar}__" />
(This does rely on ${myVar} being a valid string for the th:attr property, so you'll have to be careful with it.)
I would like to use in my project highcharts and jsf both. I have a managedbean, which has a list and it is initializing by a facade (it do a query in my database). If I'd like to pass the value of the list to highcharts, how can do this?
if anyone has a good idea, please share.
Best regards and thanks a lot
Haven't worked with highcharts , but I did with other charting library...
I'll give you general Instructions on how to combine js based charting directory it with JSF (I'm sure that there are others way's like using servlets and etc...)
1) build a working "hard coded" js only example in your JSF project
include the relevant *.js files needed by the library
add the "container" div that is required to your page
and finally wrtie the js script that build your chart with hard coded values
2) place your hard coded values into your Bean String property and place a ref' to that property in your .xhtml page something like that <h:inputHidden id="chart_input_data" value="#{myBean.valueOfChart}" /> and access it in your js code like that
//I used jQuery selectors....
var data_for_chart = $('input[id$="chart_input_data"]').val(); //you can use a simpler selector like $("#chart_input_data") too
than use the variable data_for_chart as chart series input (or for whatever parameter of your chart constructor)
3) finally I guess you would like to turn some list of Pojos into a proper json format which is most like wold "fit like a glove" for the HigthCharts constractor , this you can achieve with Gson library something like gson.toJson(yourListOfValues) see Gson user guide
Note
This technique should work for all charting library's , such as flot , flotr2 , gRaphael , jqPlot and more...
I'm using google-api-adwords-java to download some Ad Hoc AdWords reports.
The library helps me to build the request xml through usage of:
com.google.api.adwords.lib.utils.v201109.ReportUtils.toXml(reportDefinition)
I am successfully able to obtain the response xml, but I see no way through the API to map that to java objects. Is there anything within the API to help me do so or is this something I am going to have to do on my own?
(I am currently using adwords-api-8.4.2)
You will have to parse the xml on your own, since report downloads don't have corresponding POJO objects in AdWords API. Though, it should be easy to do using some basic XML parsing code. All the reports (when downloaded in xml format) looks like this:
<report>
<report-name name="Report name here"/>
<date-range date="date-range-here"/>
<table>
<columns>
<column name="columnName" display="Display name of column"/>
....
</columns>
<row columnName="value" columnName="value" .../>
....
</table>
</report>
I also wanted to mention that our primary discussion forum is at http://groups.google.com/group/adwords-api?pli=1, and I frequently answer developer questions there, so if you have any followup questions, feel free to ask there and I'll be happy to answer your questions.
Cheers,
Anash
I'm wondering if (and if so, how) it's possible to make RESTEasy return an object with custom atom links, such as links to next/previous page when paginating, particularly what I want to get is something akin to the following:
<collection>
<start>4</start>
<values>4</values>
<total>20</total>
<item>...</item>
<item>...</item>
<item>...</item>
<item>...</item>
<atom:link rel="next" href="...?page=3"/>
<atom:link rel="previous" href="...?page=1"/>
<atom:link rel="first" href="...?page=1"/>
<atom:link rel="last" href="...?page=5"/>
</collection>
I've worked out how to give links for discovery, but making custom links like this appears to be more complicated, if at all possible.
In the end I've ended up using the <any/> element and creating my own Elements to insert in to the any field of the JAXB objects. That seems to have its own problems, but at least it's a step further.
Just wanted a clear answer for a direct question -- google results have been all over the place or don't address the combos you'll see below.
I'm generally a JSP newbie and have been screwing around with the following code.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
cssClass="contentTextInput" cssStyle="width: 229px" />
When I put that into my JSP page and load my website, it works fine and looks as my cssClass defines it. Then I start messing with it because I want it to display a default value.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
value="blah" cssClass="contentTextInput" cssStyle="width: 229px" />
Suddenly, HTTP 500, an org.apache.jasper.JasperException! So I decide to remove the path altogether, while leaving in the value. This is just step 1 in something I know works because of prior experience. The code is now:
<form:input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
That actually throws an exception, too -- but then I remove the form prefix and it works-- mostly. You see, the cssClass's effects are now gone; it looks like a regular, unaffected input textbox. Here's the code so far.
<input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
What exactly do these attributes (and prefix) do that makes this mix-and-match work?
I'm guessing you're dealing with a jsp page that relies on a JSP custom tag library that's part of the Spring Framework. Here are the docs for the <form:input> tag. value is not a valid attribute for this custom tag as you can see in the docs link I provided above. When you remove the form:, you're turning the tag into a plain old HTML <input> tag which is why your error is going away at that point. It's also why your css stops working. cssClass is not the correct attribute for the HTML <input> tag. It's simply class. They called it cssClass in the jsp custom tag lib most likely to avoid a lower level collision with the Object.getClass() method (long story, just take my word for it).