How can I control the key with IzPack class? - izpack

I'm trying to control the product key with IzPack. I did it with RegularExpressionClass but, I should write my own class to control lots of key.
I use it as below, but I can not do the same thing with the class.
<userInput>
<panel id="keyControl">
<field type="rule" align="left" variable="the.password">
<spec txt="the key:"
layout=" O:6:6 "/>
<validator class="com.j32bit.installer.validator.RegularExpressionValidator" txt="wrong key!!" id="lang pack key for the error text">
<param name="pattern" value="asd"/>
</validator>
</field>
</panel>
</userInput>
I hope, my explanation is understandable.
Thanks for help.

You can change the message by overriding getErrorMessageId method with your validator class:
#Override
public String getErrorMessageId()
{
return "Your.error.message";
}
Where Your.error.message points to the particular key from CustomLangPack XML file(s):
<str id="Your.error.message" txt="Enter text here" />

Related

How can I post the same data to two different handlers depending on the button clicked?

[See updates at bottom]
I have a Razor page with a form on it. I want to have two buttons on that form, that perform a slightly different action - both using the same posted form data.
I tried using the asp-page-handler helper on the second button, but it doesn't seem to add anything to the HTML (I would expect it to add a formaction attribute to the <button> element, but it doesn't add anything at all).
Here's an example page:
#page "{id?}"
#model IndexModel
#tagHelperPrefix x:
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<p>Current value is #Model.Foo</p>
<x:form method="post">
<input type="text" name="foo" />
<button type="submit">Default</button>
<button type="submit" x:asp-page-handler="Alternative">Alternative</button>
</x:form>
... and here's the corresponding page model:
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace MyWebApplication.Pages
{
public class IndexModel : PageModel
{
[BindProperty]
public string Foo { get; set; }
public void OnGet(int? id)
{
}
public void OnPostAsync(string foo)
{
Foo = foo;
}
public void OnPostAlternativeAsync(string foo)
{
Foo = foo.ToUpper();
}
}
}
This is rendered as:
...where the generated HTML for the form is:
<form method="post">
<input type="text" name="foo" />
<button type="submit">Default</button>
<button type="submit" x:asp-page-handler="Alternative">Alternative</button>
</form>
The fact that the x:asp-page-handler attribute is still in the generated HTML makes me think that the Razor engine hasn't recognized it. I've tried taking off the x: prefix, but that didn't help.
What am I doing wrong?
UPDATE
OK, I tried removing the tag prefix and removing the #tagHelperPrefix line, and that made a difference. A formaction is added to the second <button> element as expected.
However:
that's really annoying - the #tagHelperPrefix is not something I want to lose, and
now both buttons are triggering the "Alternative" action, even though only one of them has the formaction!
Here's the new generated HTML:
<form method="post">
<input type="text" name="foo" />
<button type="submit">Default</button>
<button type="submit" formaction="/?handler=Alternative">Alternative</button>
</form>
SECOND UPDATE
OK, so If I put asp-page-handler="" on the "default" button, then each button goes to the correct handler, which is fine.
The last question that remains, then, is: how can I make this work with the tag helper prefix?
[Answering my own question in case this helps others.]
It turns out that:
The tag-helper-prefix only applies to elements, not attributes, so it should be asp-page-handler="..." rather than x:asp-page-handler="..." even if the tag-helper-prefix is x:.
Those asp- attributes are only recognized within a tag that is tag-helper-enabled - which is all elements when no tag-helper-prefix is specified, or only elements with the tag-helper-prefix where one is specified. In my case, I had to change <button ...> to <x:button ...>.
If you specify asp-page-handler for one button, you need to specify it on all the buttons, even if you specify it as "" to get the default action.

How can I render the input with type='text' in blazor server-side?

Here are the codes:
<EditForm OnValidSubmit="#SubmitText" id="inputText">
<InputText #bind-Value="_InputMsgModel.Msg" />
</EditForm>
After the program ran, it turned out to be this:
<form id="inputText">
<input class="valid">
</form>
Now I wanna add an attribute type="text" to the input element, how can I achieve this?
I tried to modify the code like this:
<EditForm OnValidSubmit="#SubmitText" id="inputText">
<input type="text" #bind-Value="_InputMsgModel.Msg" />
</EditForm>
Meanwhile, now visual studio reports an error:
I can not bind the model anymore.
I need to set the type to text for needing to set the keyboard in mobile correctly.
How can I solve this? Thank you.
What is wrong with this code:
<EditForm Model="#_InputMsgModel" OnValidSubmit="#SubmitText" id="inputText" >
<InputText #bind-Value="#_InputMsgModel.Msg" />
</EditForm>
Run this code with the above:
#code {
InputMsgModel _InputMsgModel = new InputMsgModel();
private void SubmitText()
{
Console.WriteLine(_InputMsgModel.Msg);
}
public class InputMsgModel
{
public string Msg { get; set; } = "My new message";
}
}
Do you see the text "My new message" in the text box ? I believe you do... All is well, and the two-way binding mechanism works well. Go and see now the Html...it's still <input class="valid"> which does not reflect the real state of the text box. Think about it...
Update: Of course you can use the following:
<EditForm Model="#_InputMsgModel" OnValidSubmit="#SubmitText" id="inputText" >
<input type="text" #bind-value="#_InputMsgModel.Msg" />
</EditForm>
Important: The error "The attribute names could not..." is triggered because you use capital "V" in #bind-Value. You should use lower case: #bind-value. This is because your using input 'Html element' here, and it has a value attribute, not a Value attribute. But when you use the InputText Component, the capital Value in #bind-Value refers to a Value property defined in the component.

How to use Chatter in Odoo?

I want to use Chatter for students model, so that, when value of some field is changed then it is logged under student form
To achieve this, I did the following things:
1. Added this div
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
in the student form.
It added the chatter, but when i clicked on New Message button, it gave the following error.
This could be because i haven't inherited mail.thread in student model.
Then i inherited this class in student model.
Then it again gave an error as shown below
I search this topic, but couldn't found anything.
It would be appreciated if someone could help me out.
In order to log changes of specific fields you need so set the track_visibility attribute on each field you want to track:
class OpStudent(models.Model):
_name = 'op.student'
_inherits = {
'res.partner': 'partner_id',
}
_inherit = [
'mail.thread',
'ir.needaction_mixin',
]
foo = fields.Char(track_visibility='always')
You may read more about it in the official documentation.
You're using Chatter for keeping the track on student details.
So I'll suggest another module which is working absolutely fine and keeps the track on student or any other model you want as I have personally used it.
I used audit log. It tracks all the CRUD operations. It will create Audit
the menu in setting tab from there you can set the model which you want to track.
For reference you can check this image also.
I had the same problem, but with res.company, I solved it like this:
class ResCompany(models.Model):
_name = 'res.company'
_inherit = ['res.company','mail.thread', 'mail.activity.mixin']
date_end = fields.Date(string="Fin Date",tracking=True)
and in xml:
<xpath expr="//form/sheet" position="after">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread" />
</div>
</xpath>
I hope, that it serves you.

How to send parameter to fileUploadListener in PrimeFaces fileUpload

When I create a model I would like to save images for a model. I am using PrimeFaces fileUpload component. When I save pictures I want to know to which model particular image refers to. That's why I need to send id of a model to backing bean.
Is there any possibility to send id of model to fileUploadListener?
<h:form enctype="multipart/form-data">
<p:panelGrid columns="2">
<h:outputLabel for="hotelName" value="#{msg.hotelName}"/>
<p:inputText value="#{apartmentNew.name}" id="hotelName"/>
<h:outputLabel for="hotelDescription" value="#{msg.hotelDescription}"/>
<p:inputText value="#{apartmentNew.description}" id="hotelDescription"/>
<h:outputLabel for="hotelImages" value="#{msg.hotelImages}"/>
<h:form enctype="multipart/form-data">
<p:fileUpload id="hotelImages"
fileUploadListener="#{apartments.handleImageUpload}"
mode="advanced"
sizeLimit="10000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/">
</p:fileUpload>
</h:form>
</p:panelGrid>
<p:commandButton id="saveApartmentButton" value="#{msg.save}" action="save"/>
<p:commandButton id="cancelCreationApartmentButton" value="#{msg.cancel}"
action="cancel"/>
</h:form>
Not via request parameters. You can do so via component attributes.
E.g.
<p:fileUpload ...>
<f:attribute name="foo" value="bar" />
</p:fileUpload>
with
String foo = (String) event.getComponent().getAttributes().get("foo"); // bar
I needed to pass a key parameter along with the uploaded file. I found that fileUploadListener executes during the APPLY_REQUEST_VALUES phase, so I could not use an EL expression in the f:attribute tag. I also tried to find the value using event.getComponent().findComponent("id"), but although the component was present, the value was null. I think a #ViewScoped bean would fix the missing value, but I am stubbornly attempting to keep my beans at #RequestScoped until I have absolutely no other option. Ultimately, I had to use FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id") which I got from http://forum.primefaces.org/viewtopic.php?f=3&t=6432
Error in types:
String foo = event.getComponent().getAttributes().get("foo");
Instead, do it this way:
Object foo = event.getComponent().getAttributes().get("foo");
Integer foo = (Integer) event.getComponent().getAttributes().get("foo");
You can use:
<div onclick="#{myBean.myMethod(myParam)}" >
<p:fileUpload id="fileUpload" fileUploadListener="#{myBean.onFileUplod}" mode="advanced" dragDropSupport="true"
update=":messages" process="#this" >
</p:fileUpload>
</div>
Method in myBean:
public void myMethod(String myParam) {
selectedMyParam = myParam;
}
Then you can use selectedMyParam in onFileUpload method.

Disabling radio button in jsp based on map value struts2

I'm trying to use a boolean value returned from a map in my bean to either disable/enable a radio button in a jsp page.
Class snippet:
public class Options{
private String optionId;
private Map<String,Boolean> negativeMap;
public setNegativeMap(Map<String,Boolean> negativeMap){
.......
}
JSP snippet:
<input id="radioClick<s:property value=optionId"/> type="radio" disabled="%{negativeMap[optionId]}" />
Am I on the right track with this? Is there something I'm missing?
Please, I think your JSP snippet was wrong near "value=optionId"/>" :
<input id="radioClick<s:property value=optionId"/> type="radio" disabled="%{negativeMap[optionId]}" />
Your JSP snippet should be like this :
<input id="radioClick<s:property value=optionId/>" type="radio" disabled="%{negativeMap[optionId]}" />